This is in AS2. I have been having an issue with getting the jumping I'm trying to set up to work, and I think I know why it's not working, but I don't know how to correct it. Here's what I have for the hittest with the ground (hopefully I use the code tags right):
while(_root.background.ground.hitTest(_root.stick._x, _root.stick._y, true)){
_root.stick._y -= 1;
grav = 0;
grounded = true;
}
The code for the jumping is such:
else if(this==_root.background.jumpbutton and grounded){
grav = 14;
jumping = true;
grounded = false;
}
It's set so that once the jumpbutton is pressed and if the character is touching the ground, he jumps. However, as far as I can tell, the hittest is causing the character to continually move up by 1 pixel until it's not touching the ground, and that's causing the jump to not function sometimes (it only works part of the time).
How could I go about setting this up more efficiently? I've been checking tuts, but haven't had much luck. I know what's wrong, but haven't yet thought of a better solution, and I know it's something simple I'm missing. Any help would be greatly appreciated.