Game Twister
Would you like to react to this message? Create an account in a few clicks or log in to continue.


These forums are closed for viewing purposes only. To join the Game Twister community, please register at the new forums here.
 
HomeHome  Latest imagesLatest images  SearchSearch  Log inLog in  RegisterRegister  

 

 issue with jumping script

Go down 
AuthorMessage
Reauk
Admin
Admin
Reauk


Number of posts : 232
Age : 30
Location : Hellish Nightmare Called Earth
Registration date : 2009-01-09

issue with jumping script Empty
PostSubject: issue with jumping script   issue with jumping script EmptySun Jan 25, 2009 8:08 am

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.
Back to top Go down
 
issue with jumping script
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
Game Twister :: MultiMedia :: Flash-
Jump to:  
Powered by phpBB © 2001, 2002 phpBB Group
Free forum | ©phpBB | Free forum support | Report an abuse | Forumotion.com