SEARCH
Newsletter
Subscribe to get design tips, latest trends, free stuff and more.
It doesn't look like an e-mail address

hosting

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.

subscribe to newsletter