Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > General > Gaming and Game Development

Reply
 
Thread Tools Rate Thread Display Modes
Old 03-18-2002, 12:32 PM   #1
dramarc
Registered User
 
Join Date: Dec 2001
Location: Australia/Sweden/Norway
Posts: 54
Default jumping +game!

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
dramarc is offline   Reply With Quote
Old 03-18-2002, 12:40 PM   #2
fatass
Registered User
 
Join Date: Mar 2002
Posts: 9
Default

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!
fatass is offline   Reply With Quote
Old 03-18-2002, 12:46 PM   #3
dramarc
Registered User
 
Join Date: Dec 2001
Location: Australia/Sweden/Norway
Posts: 54
Default state?

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
dramarc is offline   Reply With Quote
Old 03-18-2002, 12:53 PM   #4
fatass
Registered User
 
Join Date: Mar 2002
Posts: 9
Default

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.
fatass is offline   Reply With Quote
Old 03-18-2002, 04:37 PM   #5
dramarc
Registered User
 
Join Date: Dec 2001
Location: Australia/Sweden/Norway
Posts: 54
Default a little confused..

Hi agian!
I'm not really following your ideas and your script..
What will prohibit the jump action from beeing executed ?

best regards
/anders
dramarc is offline   Reply With Quote
Old 03-18-2002, 04:43 PM   #6
fatass
Registered User
 
Join Date: Mar 2002
Posts: 9
Default

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..
fatass is offline   Reply With Quote
Old 03-18-2002, 04:53 PM   #7
dramarc
Registered User
 
Join Date: Dec 2001
Location: Australia/Sweden/Norway
Posts: 54
Default I think I get it..

Thanks! I'll try!

/anders
dramarc is offline   Reply With Quote
Old 03-19-2002, 10:23 AM   #8
dramarc
Registered User
 
Join Date: Dec 2001
Location: Australia/Sweden/Norway
Posts: 54
Default hmmm...

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
dramarc is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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


All times are GMT. The time now is 04:30 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.