charging Timer doesn't quite work?
I'm writing a game where I want the character to jump after holding the
spacebar to charge their jump up for a bit and then the charge will get
added into the jump afterwards.
However, the code that I currently have going only works around 50% of the
time, and will almost indefinitely not work if the player is holding a
directional movement button down at the same time.
function greenTimerHandler(e:TimerEvent){
if(spacePressed&&downBumping){
charge += 3;
if(charge >= 50){
charge = 50;
}
} else if(!spacePressed&& downBumping) {
greenSlimeJump(charge);
greenSlimeTimer.stop();
}
}
//And the jump function
function greenSlimeJump(greenCharge){
ySpeed = greenCharge * -1.5
slimeAmt -= Math.floor(greenCharge * 0.25);
charge = 0;
}
the downBumping is just a boolean collision value based on a hitTestPoint
for the bottom of the player...
Is there any way that I can make it so that it actually runs the jump
function more than it currently does? It will even keep the charge value
for the next time it tries to jump and the slimeAmt value is never
subtracted because the code just seems to completely skip the green jump
function altogether.
I can upload the swf of my game to a hosting website if need be but I kind
of dont want it to be shown on such a public forum. Thanks!
No comments:
Post a Comment