Our Swish tutorials provide you with step-by-step instructions on how to create beautiful Flash animations and integrate them into your website.  Home Flash & Swish Swish Tutorials Character Jump
Your Ad Here

Character Jump


Example:

Click on the movie above and Press The Control Button "Ctrl" to make the character jump.

Lets start by opening SwishMax, set you movie size to 200 x 150

Step. 1

Create a character, or if you already have one just import it into swishmax.

Group as a sprite and name "Character".

Now add the following code to the "Character" sprite.

onLoad () {
// jumping variables
startspeed = 10;
gravity = 12.8;
jumping = 0;
}
onEnterFrame() {
// jumping key is "Ctrl" keyboard number 17
if (Key.isDown(17) and jumping==0) {
jumping = 1;
starttime = getTimer()/1000;
startposition = _y;
}
if (jumping==1) {
time = getTimer()/1000-starttime;
_y = _y-(startspeed-gravity*time);
if (_y>startposition) {
_y = startposition;
jumping = 0;
}
}
}

That's It, now press Ctrl+T to test your movie.



Author's URL: Craig Lowe
Thank you for voting.
Rate this Materials:
Bad 
1 2 3 4 5 Excellent
print this page subscribe to newsletter subscribe to rss

Internet & computing Flash is a vector-based moving graphics format created by Macromedia for the publication of animations on the World Wide Web. More Flash & Swish: Most Popular Materials | Fresh Materials | More Swish Tutorials at FlashPerfection.com

Add comments to "Character Jump"

Only registered users can write comment

Reader's comments