| Home | Tutorials | Forums | Articles | Blogs | Movies | Library | Employment | Press | Buy templates |
|
|
#1 |
|
Registered User
Join Date: Dec 2001
Location: Australia/Sweden/Norway
Posts: 54
|
Hi!
I'm working on a game and I have a problem that's reallay annoying me! I want my kick-ass Flash soldier to jump when I press a key: THe problem I have is that if the button is held down, the jump scrip just keeps going and going and my character starts flying away! (move out of the screen). I what the jump-script only be executed when the charater is on the ground and not while airborne! I've tried different ideas with button scripts, booleans etc, but none of the work! ANy suggestionS! /anders |
|
|
|
|
|
#2 |
|
Registered User
Join Date: Mar 2002
Posts: 9
|
You could try having a state attached to the man, i.e. manState = "walking"; for when he's walking or manState = "jumping" for when he's jumping.
Then when you call the jump function wrap an if around the code: if (manState != "jumping") { //do all your jumping stuff and add manState = "jumping"; } that way it will only be called once. When he lands change the manState back to walking and off you go! |
|
|
|
|
|
|
|
|
#3 |
|
Registered User
Join Date: Dec 2001
Location: Australia/Sweden/Norway
Posts: 54
|
What do you mean by state? Like a label inside the movieclip (the character) One for walking and one frame for jumping including the jumpscript?
/anders |
|
|
|
|
|
#4 |
|
Registered User
Join Date: Mar 2002
Posts: 9
|
I mean like a variable.
If you have 1 variable which controls the state of your man, you can make sure he only does 1 thing at a time, walking or jumping. Did you get the script bit of the post? I mean for the state to be a flag or switch forcing the jump script to only run once. |
|
|
|
|
|
#5 |
|
Registered User
Join Date: Dec 2001
Location: Australia/Sweden/Norway
Posts: 54
|
Hi agian!
I'm not really following your ideas and your script.. What will prohibit the jump action from beeing executed ? best regards /anders |
|
|
|
|
|
#6 |
|
Registered User
Join Date: Mar 2002
Posts: 9
|
the if statement
if (manState != "jumping") { //make the little blighter jump manState = "jumping"; } if the state switch (manState) is NOT equal to "jumping" then execute the jump code AND set the state switch to equal "jumping". Therefore when your key press tries to run the jump code again, it gets to the if statement and says: OH, manState is "jumping", in that case I won't make him jump again, cos he already is. Then when he lands set the switch back to "walking" or whatever, as long as its not "jumping" because otherwise, he will never jump again. hope that helps. Paul Last edited by fatass; 03-18-2002 at 04:46 PM.. |
|
|
|
|
|
#7 |
|
Registered User
Join Date: Dec 2001
Location: Australia/Sweden/Norway
Posts: 54
|
Thanks! I'll try!
/anders |
|
|
|
|
|
#8 |
|
Registered User
Join Date: Dec 2001
Location: Australia/Sweden/Norway
Posts: 54
|
Hi again!
I can't get it to work!! I've tried with booleans, but the problem remains.. I'll attach my no-good-piece-of crap script when I get home.. /anders |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Game troubles - Jumping | Kartune85 | Gaming and Game Development | 2 | 02-26-2005 05:08 AM |
| [AS2] Problems with platform game (jumping and collision issues) | Amaster | Gaming and Game Development | 6 | 09-14-2004 10:26 PM |
| [AS2] Tile game or not tile game? | krolben | Gaming and Game Development | 4 | 07-28-2004 01:41 PM |
| Trouble with my Flash game: Jumping | godstatic | Gaming and Game Development | 3 | 04-03-2003 02:24 PM |