Vectorials
Flash Perfection
3D Lessons
Tutorialkit
Markup Tutorials
Learn PHP
network
adv banner
Flash & Swish  Home Flash & Swish Swish Tutorials Character Jump
rss

Character Jump

Author: Craig Lowe More by this author


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.




Rate this Material: Bad 1 2 3 4 5 Excellent
print this page tell a friend subscribe to newsletter subscribe to rss

Add comments to "Character Jump"