Best viewed in Firefox

Awesty Productions

Platform Jumping

November 11th, 2006 by awesty

In this tutorial you will learn how to make a jumping system that could be used to make a platformer game or any other game involving jumping.

You should have taken my Moving MovieClips with the arrow keys tutorial because I will not be explaining that code.

First of all make you ground/platforms for your character to jump off and onto. If you have 1, give it an instance name of ground0. If you have 2 give them instance names of ground0 and ground1. For 3 give them instance names of ground0, ground1, ground2. If you have more than 3 you should have figured out by now what instance names to give them, if not I suggest you stop taking this tutorial and start learning English ;)

Now make the MC you want to jump and put this code on it: (Please read the comments so you understand what the code does.

onClipEvent(load){
    var jump:Number = 0; //Sets a new variable called jump with a value of 0
    var jumping:Boolean = false; //Sets a new boolean which will be false when it loads
    var falling:Boolean = false; //Read above
    var g:Number = 4; //This variable should be how many grounds you have. (If it goes up to ground2, then to should have 3 grounds. ground0, 1 and
}
onClipEvent(enterFrame){
    if(jumping == true || falling == true){ //If it is jumping or falling (|| means or)
        this._y -= jump; //The _y coordinates increase by the variable jump
    }
    if(jumping == false){ //If jumping is false
        if(!falling){ //If falling is false (! mean not, so !falling means not falling)
            jump = 0; //Jump equals 0
    }
        if(Key.isDown(Key.UP)){ //If the up arrow key is down…
            jump = 15; //Jump equals 15 and…
            jumping = true  //Jumping is true
        }
       
    }
    if(jumping == true){ //If jumping is true…   
        jump -= 1; //Jumping decrease by 1
    }   
    if(jump <= -10){ //If jump is equal to or less than negative 10…
        jump = -10; //Jumping equals -10. Then it will not go any lower than -10
    }   
    for(i=0;i<g;i++){ //This is a for loop. It keeps doing the code in between the curly braces until the condition (i<g) is false. g is the variable that has the number of grounds.
        if(jumping == true && this.hitTest(_root["ground"+i])){
/*If jumping is equal to true (jumping == true), and (&&) if this hits any of the grounds… (_root["ground"+i] will be _root.ground and then whatever i equals, so if i = 2, it would be _root.ground2. Since it is in a loop it will equal all the numbers to match all your grounds, if you get what I mean. That probably didn’t make make much sense.*/
            jumping = false; //Jumping equals false        
        }
    }
    if(Key.isDown(Key.LEFT)){ //You should have taken my moving movieclips with the arrowkeys tutorial so I won’t need to explain this.
        this._x -= 5;
    }else if(Key.isDown(Key.RIGHT)){
        this._x += 5;
    }
    for(i=0;i<g;i++){ //Another loop
        if(!jumping && !this.hitTest(_root["ground"+i]) && !falling){ //If jumping is flase and this isn’t hitting any of the grounds and falling is false…
            falling = true; //Falling is true and…
            this._y -= 1; //This _y decreases by 1 so it doesn’t fall through.
        }
    }
    if(falling == true){ //If falling is true
        for(i=0;i<g;i++){ //Another loop
            if(this.hitTest(_root["ground"+i])){ //if this hits any of the grounds…
                falling = false; //falling is false
            }
        }
        jump -= 1; //jump decreases by one     
    }   
}

Please don’t just copy and paste that code, please read all the comments so you know what it means.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • blinkbits
  • BlinkList
  • blogmarks
  • del.icio.us
  • digg
  • Furl
  • MyShare
  • NewsVine
  • Netscape
  • Reddit
  • Simpy
  • Slashdot
  • StumbleUpon
  • Technorati
  • YahooMyWeb

RSS feed | Trackback URI

183 Comments »

Comment by joey
2006-11-11 14:46:42

ive added this to my character and well theres a couple of errors and im not the bast at flash so i cant always figure it out so wat do you think:
**Error** Scene=Scene 1, layer=Layer 1, frame=4:Line 63: ‘)’ expected
if(jump $lt;= -10){ //If jump is equal to or less than negative 10…

**Error** Scene=Scene 1, layer=Layer 1, frame=4:Line 66: ‘;’ expected
for(i=0;i

Total ActionScript Errors: 2 Reported Errors: 2

Comment by ABBA Subscribed to comments via email
2007-07-08 05:32:03

I don’t reply to this comment but i didn’t find the new comment button or such thing.
Can’t you make the comments so shorter? It’s WAY to long! And i can’t read it cause the letters is too small! Fix this please. Anyway your other tutorials are great!

 
 
Comment by joey
2006-11-11 18:36:17

dont worry ive figured it out thanks for the tutorial and may i ask if you could make one on A.I. i would praise you if you did thx

 
Comment by awesty
2006-11-12 09:56:08

Yea, I will make one soon. Maybe today.

Also you must have got the code the same second I posted it because I made a few mistakes and I fixed it pretty much instantly so the code should be right now.

Comment by Izzy
2007-08-30 11:33:50

awesty you have so much extra code for the ground and all i want to know how to do is jump…help me plz

 
 
Comment by hbradley
2006-11-12 10:34:51

thanks for the tutorials.
they’re great

but on this one when ever I test it my man just appears in the middle and falls below the screen

any ideas?

thanks

Comment by Kurt Subscribed to comments via email
2007-11-06 07:14:03

Well you have to put a platform below it lol.

 
 
Comment by joey
2006-11-12 17:32:16

yea i did awesty it works pretty good now thx im looking forward for the AI one

hbradley i had the same problem with the falling through but it turned out that i forgot to name the ground movieclip ground0 that maybe the problem but im no expert.

 
Comment by hbradley
2006-11-13 02:31:19

thanks joey
I’ll check and see

 
Comment by awesty
2006-11-13 16:06:06

Okay, I am going to try and write two new tutorials tonight. The AI one will be the second so that might not get finished.

 
Comment by Webber
2006-11-16 14:05:53

can someone put what im suppose to put without explaining parts, ive read its just its getting annoying taking it out :p

 
Comment by someone
2006-11-16 15:06:37

webber are you a complete idiot take it out yourself dont be a lazy bitch

 
Comment by someone
2006-11-16 15:07:43

y are you so lazy do it your self

 
Comment by Webber
2006-11-17 06:36:19

bcz i did and it didnt work so i screwed something up and i dont understand the error box

 
Comment by awesty
2006-11-17 09:35:07

I did that purposely so people like you couldn’t just copy and paste it in. If you can really understand the code (which you should once you read all the comments) it should be simple to fix it. ;)

 
Comment by Webber
2006-11-17 11:01:30

i did but i didnt understand :(

 
Comment by awesty
2006-11-18 09:44:38

Okay, comments are marked with a //. That way flash knows it’s a comment and not code, so anything after a // that doesn’t look like code you can remove. Multi-line comments a marked with a /* and closed with a */ so anything between them you can delete to ;)

 
Comment by Webber
2006-11-19 08:02:04

and ofcourse the platforms should be MC?

 
Comment by bobby
2006-11-19 08:33:40

awesty ure tutorials are quite hard to follow, the health system thing neva worked for me, and now neither is this :( none of ure comments start with /* so its quite hard to tell if theyre multiline or not

 
Comment by awesty
2006-11-19 09:19:18

MC = Movieclip

Anything that follows // and doesn’t look like code get rid of. I can’t make it any clearer.

 
Comment by pushasha
2006-11-20 13:16:00

I understand all the comments because I do a lot of programming with other languages, but I’m not so experienced with Actionscript. I keep getting the following error and have tried to fix it multiple times, but I hasn’t been working. It might be because I’m using Flash MX 2004…

**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 36: Operator ‘&&’ must be followed by an operand
if(jumping == true && this.hitTest(_root[”ground” i]==true)){

**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 47: Operator ‘!’ must be followed by an operand
if(!jumping && !this.hitTest(_root[”ground” i]) && !falling){

**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 53: Syntax error.
if(this.hitTest(_root[”ground” i])){

Total ActionScript Errors: 3 Reported Errors: 3

 
Comment by pushasha
2006-11-20 13:18:40

Actually, on the third line of the error I just posted, I should have entered it this way:

if(jumping == true && this.hitTest(_root[”ground” i])){

I added the “==true” when I was trying to fix it…

 
Comment by awesty
2006-11-20 17:23:31

That is weird, the code works fine for me. It should work fine with flash MX 2004. Are you are it is 2004, if not that would explain the problem.

 
Comment by Mark
2006-11-23 15:50:06

Awesty — thank you much for your tutorials. I’ve started going through them all tonight and have a super basic interactive sort-of game created already. I like your short-and-sweet approach (I’m a developer so it’s just the pace I need), but I hate the way it’s all formatted.

Your indentations are lost in HTML making the code kinda hard to read unless I view source, but then I have to trim out all the ’s and replace all the & with &.

Maybe you can use tags around your code samples?

 
Comment by Mark
2006-11-23 15:51:20

Er my comment got botched. The last line should’ve ready “Maybe you can use <pre> tags around your code samples :P

 
Comment by awesty
2006-11-23 15:53:23

Yea, i did but then the comments ran to long and off the page :P

 
Comment by Joe
2006-11-25 07:55:01

Is this for flash 8?
i doesnt work for me. i just got flash and i dont know a thing. HELP PLEEZE!

 
Comment by unknown
2006-11-26 00:59:09

wow… i never thought there could be a tutorial so great! thanx! gave me good stuff in my “maze” game!

 
Comment by moo moo
2006-11-26 14:46:20

what comes after ground4?

 
Comment by awesty
2006-11-27 16:07:58

@Joe: Yes, it is for flash 8. I cant really help you if I don’t know exactly whats wrong.

@Unknown: No problem. ;)
@Moo moo: ground7

 
Comment by sam
2006-11-28 08:52:56

how do u make a menu and a button that will activate the flash game?

 
 
Comment by Bryce K :P
2006-12-01 11:33:04

okay to put it simple this does not work at all there are to many errors and frankly my guy doesnt move AND YES I DID PUT THE MOVEMENT ON HIM FROM UR LAST TOT

 
Comment by awesty
2006-12-01 16:24:41

Well that doesn’t really help me to help you.

Just calm down and send the .fla to admin[@]awestyproductions[.]com.

 
Comment by Bryce K :P
2006-12-02 10:48:19

lol sry i was kidding i just couldnt ghet it 2 work but its ok i was just kidding :P

 
Comment by Bryce K :P
2006-12-02 10:50:05

but just incase u wanted to no there is a Jumping thing on Flashkit.com and it has less action script errors and it usually works except for 1 thing maybe you could hunt it down and modify it. (it will let u download the .fla file :))

 
Comment by RedV
2006-12-02 13:52:44

my guy just keeps falling through the blocks
but there aren’t any error messages
please help!

 
Comment by Bryce K :P
2006-12-03 11:51:59

Umm Awesty i didn’t copy and paste this, i have 9 errors ._. plz help
**Error** Line 1: Clip events are permitted only for movie clip instances
onClipEvent(load){

**Error** Line 6: Clip events are permitted only for movie clip instances
onClipEvent(enterFrame){

**Error** Line 26: This type of quotation mark is not allowed in ActionScript. Please change it to a standard (straight) double quote.
if(jumping == true && this.hitTest(_root[”ground” i])){

**Error** Line 36: This type of quotation mark is not allowed in ActionScript. Please change it to a standard (straight) double quote.
if(!jumping && !this.hitTest(_root[”ground” i]) && !falling){

**Error** Line 42: This type of quotation mark is not allowed in ActionScript. Please change it to a standard (straight) double quote.
if(this.hitTest(_root[”ground” i])){

**Error** Line 6: Statement block must be terminated by ‘}’
onClipEvent(enterFrame){

**Error** Line 50: Syntax error.

**Error** Line 1: Statement block must be terminated by ‘}’
onClipEvent(load){

**Error** Line 50: Syntax error.

 
Comment by awesty
2006-12-03 17:37:05

@RedV: Did you get all the instance names on the right movieclips?

@Bryce K: It looks like you have out the script on a frame instead of a movieclip.

 
Comment by Adman
2006-12-04 02:28:32

My character sinks in to the gournd slightly when he hits it. How can i stop thi=s from happening?
Also can u make a tutorial for scrolling backround please!!!

 
Comment by Bryce K :P
2006-12-04 03:02:01

awsety i made the changes but i still have 2 errors

**Error** Scene=Scene 1, layer=Layer 1, frame=15:Line 26: Statement block must be terminated by ‘}’
onClipEvent(load){

**Error** Scene=Scene 1, layer=Layer 1, frame=15:Line 71: Syntax error.
}

 
Comment by Bryce K :P
2006-12-04 03:04:17

dangit i cant go any farther lol (sry i took up so much space ill e-mail my script to you)

 
Comment by awesty
2006-12-04 12:41:22

@Adman: Try changing it to this:
onClipEvent(load){
var jump:Number = 0; //Sets a new variable called jump with a value of 0
var jumping:Boolean = false; //Sets a new boolean which will be false when it loads
var falling:Boolean = false; //Read above
var g:Number = 4; //This variable should be how many grounds you have. (If it goes up to ground2, then to should have 3 grounds. ground0, 1 and
}
onClipEvent(enterFrame){
//if(jumping == true || falling == true){ //If it is jumping or falling (|| means or)
this._y -= jump; //The _y coordinates increase by the variable jump
//}
if(jumping == false){ //If jumping is false
if(!falling){ //If falling is false (! mean not, so !falling means not falling)
jump = 0; //Jump equals 0
}
if(Key.isDown(Key.UP)){ //If the up arrow key is down…
jump = 15; //Jump equals 15 and…
jumping = true //Jumping is true
}

}
if(jumping == true){ //If jumping is true…
jump -= 1; //Jumping decrease by 1
}
if(jump <= -10){ //If jump is equal to or less than negative 10…
jump = -10; //Jumping equals -10. Then it will not go any lower than -10
}
for(i=0;i if(jumping == true && this.hitTest(_root[”ground” i])){
/*If jumping is equal to true (jumping == true), and (&&) if this hits any of the grounds… (_root[”ground” i] will be _root.ground and then whatever i equals, so if i = 2, it would be _root.ground2. Since it is in a loop it will equal all the numbers to match all your grounds, if you get what I mean. That probably didn’t make make much sense.*/
jumping = false; //Jumping equals false
}
}
if(Key.isDown(Key.LEFT)){ //You should have taken my moving movieclips with the arrowkeys tutorial so I won’t need to explain this.
this._x -= 5;
}else if(Key.isDown(Key.RIGHT)){
this._x = 5;
}
for(i=0;i if(!jumping && !this.hitTest(_root[”ground” i]) && !falling){ //If jumping is flase and this isn’t hitting any of the grounds and falling is false…
falling = true; //Falling is true and…
this._y -= 2; //This _y decreases by 1 so it doesn’t fall through.
}
}
if(falling == true){ //If falling is true
for(i=0;i if(this.hitTest(_root[”ground” i])){ //if this hits any of the grounds…
falling = false; //falling is false
}
}
jump -= 1; //jump decreases by one
}
}

Sorry about all the comments but I couldn\’t really be bothered taking them out.

 
Comment by awesty
2006-12-04 12:43:31

@Bryce K: I got your email and deleted your 2 other posts since they took up a far bit of scrolling space. :P
I will try and fix it when I have time.

 
Comment by Daniel
2006-12-09 08:42:35

This tutorial is great exept i got 1 error :
**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 7: Statement block must be terminated by ‘}’
onClipEvent(enterFrame){

Please help. Thank you.

 
Comment by awesty
2006-12-09 09:45:14

Just add one of theses, }, to the end of your code. It should work.

 
Comment by Daniel
2006-12-10 01:26:16

ok i did that but now my guy just falls and when i press up he flies and doesnt stand on the platforms, can i send you the .fla file?

 
Comment by awesty
2006-12-10 11:17:25

Yep. My email it admin[@]awestyproductions[.]com.

 
Comment by tyler
2006-12-12 16:01:26

hey when I try to jump onto the platform, i jump and go right through it

please help!?!?!?!

tyler

if u dont know… i wanna be able to stand on the platform

P.S. is there any way to make the enemys attack you?

 
Comment by Bryce K :P
2006-12-13 08:53:59

I tried putting “}” and “{” these everywhere but i still have these errors

**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 6: Statement block must be terminated by ‘}’
onClipEvent(enterFrame){

**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 49: Syntax error.

 
Comment by Bryce K :P
2006-12-13 08:56:31

PEOPLES IF UR GUY FALLS THERW THE FREAKIN WALL IT MEANS YOU DIDNT PUT AN INSTANCE NAME ON THE GROUND name it ground0. (Without the period)

 
Comment by tyler
2006-12-13 09:56:52

ok i did everything with instance names and the code
and speaking of the code i put it on the guy and i still have 3 errors please help and replace them…

**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 28: This type of quotation mark is not allowed in ActionScript. Please change it to a standard (straight) double quote.
if (jumping == true && this.hitTest(_root[”ground” i])){

**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 39: This type of quotation mark is not allowed in ActionScript. Please change it to a standard (straight) double quote.
if(!jumping && !this.hitTest(_root[”ground” i]) && !falling){ //If jumping is flase and this isn’t hitting any of the grounds and falling is false…

**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 46: This type of quotation mark is not allowed in ActionScript. Please change it to a standard (straight) double quote.
if(this.hitTest(_root[”ground” i])){ //if this hits any of the grounds…

Total ActionScript Errors: 3 Reported Errors: 3

 
Comment by awesty
2006-12-13 16:48:08

@Both of you: Just email the .fla’s to me. It is much easier for me to understand what is going on.

admin[@]awestyproductions[.]com

 
Comment by BeM
2006-12-14 04:39:07

Wow, what a great tut awesty! Thanks a lot. But I have one problem… my character bumps like like on each platform and when I jump and the character lands, he falls a little bit trough the platform and then he rises again. After that he starts bumping again.

Could you please help me?

Keep up the good work your tuts are great!

 
Comment by tyler
2006-12-14 13:41:30

it wont let me send it to u

 
Comment by Daniel
2006-12-15 09:57:11

I send mine to you a 10 days ago. Are you going to email back or are you going to post a comment?

 
Comment by awesty
2006-12-15 11:43:07

@BeM: Try changing the number on the last line (something like jump -= 1;) to a smaller number, is will still bump, but not as much.

@Tyler: I cant help you there.

@Daniel: Are you sure I haven\’t replied? Otherwise I mustnt have got the email.

 
Comment by BeM
2006-12-15 22:33:06

Thanks awesty, but stille my character is rising threw the platforms. For example when I jump underneath a platform and it hits a platform it starts rising up till it’s on top of that platform…

Can I do something about that?

 
Comment by Mohit
2006-12-16 01:50:58

Hey awesty,
i tried your tutorial for platform jumping buti got 12 errors. Using a basic knowledge of actionscripting i was able to understand your code and deleted the “//”s and the comments but i get the following three errors.

**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 27: Operator ‘&&’ must be followed by an operand
if(jumping == true && this.hitTest(_root[”ground” i])){

**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 38: Operator ‘!’ must be followed by an operand
if(!jumping && !this.hitTest(_root[”ground” i]) && !falling){

**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 45: Syntax error.
if(this.hitTest(_root[”ground” i])){

Total ActionScript Errors: 3 Reported Errors: 3

I am sending you the flash file document currently.
Please help. Thank you.

 
Comment by BeM
2006-12-16 02:41:26

Mohit

You need to change the ” around ground. When you do it properly it turns into green.

 
Comment by awesty
2006-12-16 17:17:56

@BeM: Try taking out the line:

jump -= 1; //jump decreases by one

@Mohit & BeM: Yea, I think its because this site as a different font, when you paste it flash cant read the quotation marks properly.

 
Comment by Bryce K :P
2006-12-17 11:21:20

yah awesty i e-mailed u like 3 weeks ago >.> and i never got a response…

 
Comment by awesty
2006-12-17 13:32:00

Hmm… I can remember emailing you back. Thats weird. I have the message in my sent box.

 
Comment by Bryce K :P
2006-12-18 00:03:12

o.. could u post it cause i guess my e-mail is screwed up

 
Comment by awesty
2006-12-18 10:52:44

onClipEvent(load){
fight = false;
}
onClipEvent(enterFrame){
if(fight == false){
if(Key.isDown(Key.LEFT) && fight != true){
this._x -= 4;
this._xscale = -100;
this.gotoAndStop(2);
}else if(Key.isDown(Key.RIGHT) && fight != true){
this._x = 4;
this._xscale = 100;
this.gotoAndStop(2);
}else{
this.gotoAndStop(1);
}
}
if(Key.isDown(Key.SPACE)){
this.gotoAndStop(3);
fight = true;
}
if(this._currentframe == 1){
fight = false;
}
}
onClipEvent(load){
var jump:Number = 0;
var jumping:Boolean = false;
var falling:Boolean = false;
var g:Number = 4;
}
onClipEvent(enterFrame){
this._y -= jump;
if(jumping == false){
if(!falling){
jump = 0;
}
if(Key.isDown(Key.UP)){
jump = 15;
jumping = true
}

}
if(jumping == true){
jump -= 1;
}
if(jump <= -10){
jump = -10;
}
for(i=0;i if(jumping == true && this.hitTest(_root[”ground” i])){

}
}
if(Key.isDown(Key.LEFT)){
this._x -= 5;
}else if(Key.isDown(Key.RIGHT)){
this._x = 5;
}
for(i=0;i if(!jumping && !this.hitTest(_root[”ground” i]) && !falling){
falling = true;
this._y -= 1;
}
if(falling == true){
for(i=0;i if(this.hitTest(_root[”ground” i])){
falling = false;
}
}
jump -= 1;
}
}
}

 
Comment by Bryce K :P
2006-12-19 00:54:04

Thanks for the help but that doesn’t work either it keeps saying all clip events have to appear on a clip handler when they are attached to a movieclip anyway could you check out my version of the game its rite here, the only thing wrong with is is you go through the ground even is the code is on it…
[url=http://www.swfup.com/swf-view.php?id=3509]View my swf file![/url]

 
Comment by Bryce K :P
2006-12-19 00:56:33

wow, thats weird i just played my game again… and i didnt fall through but on my comp. i do… cool :) anyway if you wanna see the code here it is :P (i just give the ground an instance name of ground)
onClipEvent (load) {

moveSpeed = 10;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {

this._x = moveSpeed;

}else if (Key.isDown(Key.LEFT)) {
this._x -= moveSpeed;

}
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.UP) && !jumping) {
vel_y = 36;

jumping = true;
}
if (jumping == true) {
vel_y -= 2;
if (vel_y

 
Comment by Bryce K :P
2006-12-19 00:57:44

awww dammit i hate when it gets cut off… I’ll e-mail it to u so you can make it better, if you want

 
Comment by awesty
2006-12-19 17:50:30

It won’t get cut off if you take out the angle brackets (< and >) ;)
It works fine on my computer to, maybe its the version of flash on that computer.

 
Comment by Bryce K :P
2006-12-20 11:55:35

yes i finally got it to work Thnaks for the tutorial but, my guy keeps falling through the ground XD and i have all my instance names -_-

 
Comment by awesty
2006-12-21 11:48:12

You can email it to:

awestyproductions[@]gmail[.]com

If you want. I will try and fix it.

 
Comment by Bryce K :P
2006-12-22 00:28:58

Thanx man it looks sick now :P

 
Comment by awesty
2006-12-22 11:19:14

No problem. :D

 
Comment by KIM
2006-12-22 17:26:49

I need help please? how can i make my char jump when i press up?

thnx awesty

 
Comment by awesty
2006-12-22 17:53:18

Ummm, read the tutorial.

 
Comment by KIM
2006-12-22 18:20:20

i did but it wont work…

 
Comment by RDB2006
2006-12-22 18:43:53

im about to try the platforms but theres one prob. Im gona have the platforms moving sideways in a motion tween so u hav to try and catch it, and i cant make it in a loop or it will go back to the the first frame where the health, etc, is set back to its original varible etc. Is ther anyway just to loop the tween?

 
Comment by awesty
2006-12-22 18:53:36

@KIM: Read it again, I just changed it a bit.

@RBD2006: Make the platform a MC, and tween it inside the MC. So on the main timeline it is only 1 frame.

 
Comment by RDB2006
2006-12-22 19:22:37

ty awesty this is one of the best tutz :) therz just one more thing. Is it possible to make it that if you fall of a platform, you fall, but down the bottom of the screen and a varible for your life decreases? Or something like that to indicate you lost a life

 
Comment by no1jock
2006-12-22 19:39:19

its not very accurate, it will jump onto platforms, but with platforms that are close, if you walk off one it goes up onto the other one. Maybe cuz only the surface line should be my mc, im not sure but i thought id ask

 
Comment by RDB2006
2006-12-22 20:09:50

byrce, i had the same problem if u havent fixed it already, make the platform a 0.25 line, and call it ground0 and just move it ontop of the thing u want to jump onto, i had the same prob cuz i was making a function wer u jump onto a tree, and accidently made it all a platform etc

 
Comment by Bobkins
2006-12-22 21:17:02

hey he jumps to high, can anybody help or highlight the code that tells him how high he jumps?

 
Comment by no1jock
2006-12-23 05:59:10

@RDB2006 - thanks for the advice.

 
Comment by awesty
2006-12-23 12:33:12

@RBD2006: Make a MC off the screen, and put a code like this on it:

onClipEvent(enterFrame){
if(this.hitTest(_root.man){
_root.life -= 1;
}
}

And have a dyanamic text for the health with a variable name of life.

@Bobkins: This:

jump -= 1;

And:

jump = 15;

 
Comment by eblup
2006-12-24 11:20:21

hey post a code of this only with an over head view i tried but he dosent shrink help plz it would be good for games to have an over view of this tutoreail

 
Comment by easy
2006-12-24 15:32:28

onClipEvent(load){
jump=0;
jumping=false;
falling=false;
Number=4;
}

onClipEvent(enterFrame){
if(jumping==true||falling==true){
this._y-=jump;
}
if(jumping==false){
if(!falling){
jump=0;
}
if(Key.isDown(Key.UP)){
jump=15;
jumping=true;
}
}
if(jumping==true){
jump-=1;
}
if(jump

 
Comment by waaaaaaaa
2006-12-24 15:52:35

the code aint working agin just put it all up so i can paist it without the // crap

 
Comment by FlashBack
2006-12-28 01:09:19

well awsome tutorial man.

 
Comment by awesty
2006-12-28 18:03:53

@easy: For head over view, you could just animate it.

 
Comment by eblup
2006-12-30 10:19:26

why dose my code not work

onClipEvent (load) {
up = -1;
j = false;
}

onClipEvent (enterFrame) {
if (Key.isDown(Key.UP)) {
up = 3;
j = true;
}
}

onClipEvent (enterFrame) {
if (j = true) {
up -= 1;
}
}

onClipEvent (enterFrame) {
if (up

 
Comment by awesty
2006-12-31 13:21:57

It got cut off. Email the .fla to:

awestyproductions[@]gmail[.]com.

 
Comment by Daniel
2007-01-01 03:07:02

I went through the tut and i thought i did everything right but my guy gets pulled towards the platform on top and flies. Ill send you the .fla file b/c i dont understand whats wrong.

Thanks.

 
Comment by RDB2006
2007-01-01 08:39:17

@Daniel - i think i know whats wrong… I fixed it by making my platforms more spaced apart, and the guy didn’t fly up onto them unless you jumped ontop from under them, which platform games are meant to do. I may be wrong, just a thought.

 
Comment by awesty
2007-01-01 12:06:32

Yea, just send it to:

awestyproductions[@]gmail[.]com

 
Comment by eblup
2007-01-02 16:42:14

hey next tut you make make loco roco ror the psp in flash

 
Comment by no1jock
2007-01-03 01:42:04

ebulp that would be soooo hard. But i heard sony made loco roco in flash. Cuz the graphics look so flashy.

 
Comment by awesty
2007-01-03 11:30:01

@ebulp: You think I could make a game by myself, that took sony a whole team to make?

@no1jock: Yea, they did make it in flash.

 
Comment by eblup
2007-01-03 13:58:43

hey ill send you the file i triede to make it in ok well all make it or at least try ok?

if you say ok then ill send the file and well work and for help got to

http://locoroco.com/index.html?locale=en_GB

 
Comment by awesty
2007-01-03 16:25:59

Umm… i have no idea what you said then, but my email is

awestyproductions[@]gmail[.]com

 
Comment by RDB2006
2007-01-04 05:35:04

hey eblup, try not to get too ambitious. It took hundreds of people in the sony team around 1 or 2 years to make it, and theyre profressinals. You could make a game like it, but simpler. i.e - you roll a ball and collect items, and when you hit an enemy their health goes down or something.

 
Comment by rrr444
2007-01-04 06:04:56

wow! did they really make it in flash?? and if they did does that mean i make our own flash games and send them to my PSP or something or load them onto the USB or memory card thing and play them??

 
Comment by RDB2006
2007-01-04 06:12:17

edlup, soz if that sounded slightly rude… i just meant it would be really hard to make and nobody but a team of pro’s could do it.

 
Comment by awesty
2007-01-04 08:34:27

@rrr444: I think they changed the format. I don’t think they will continue to make games in flash, it was probably a one off.
So you could try, but I doubt it would work.

 
Comment by eblup
2007-01-04 15:26:48

ya it would be hard to make and

rrr444: ive been to websites and yes they tell you how to get flash games on the psp with the new upgrade that has flash player on it

 
Comment by Punk
2007-01-05 01:05:37

Nice tutorial, but when I try and use it my person continually bounces up and down on the blocks, I’m not sure if it’s an error on your part or mine, but besides that this code works great, thanks.

 
Comment by rrr444
2007-01-05 01:22:54

cool? can you send me the link?

 
Comment by RDB2006
2007-01-05 05:08:20

@eblup: the new upgrade? I remember i got the option to install a new update on my PSP around two or three weeks ago. Maybe thats it and all you have to do is send it to your PSP or something.

 
Comment by rrr444
2007-01-05 05:13:30

WOW. everyone seems so fascinated by this. Anyway i done a google search and i got a link that tells you how to get them the flash games on your PSP

http://www.sony-psponline.com/

All you need is a WiFi connenction up and running on your PSP (a wireless internet at home) i think, but i dont have that!! :):):):):) and a flash game to put on.

 
Comment by eblup
2007-01-05 10:27:36

punk: ya, i hate how he bounces so i made my own code. and for this you only need 1 layer for ground walls and the roof. if you youse this in a game put thanks to eblup in the credits or dir lol

onClipEvent (load) {
j = 0;
c = 1;
speed = 8;
}

onClipEvent (enterFrame) {
if (_root.guy._alpha == 100) {
_root.tie = 1;
}
}

onClipEvent (enterFrame) {
if (Key.isDown(Key.UP)) {
if (c > 0) {
j = -15;
this._y -= 6;
c = 0;
}
}
}

onClipEvent (enterFrame) {
if (j > 6) {
j = 6;
}
}

onClipEvent (enterFrame) {
if(_root.ground.hitTest(_x (_width/2),_y,true)){
this._x -= speed;
}
if(_root.ground.hitTest(_x-(_width/2),_y,true)){
this._x = speed;
}
if(_root.ground.hitTest(_x,_y (_height/2),true)){
j = 0;
c = 1;
}else{
j = 1;
this._y -= j;
}
if(_root.ground.hitTest(_x,_y-(_height/2),true)){
this._y = 15;
}
}

onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
_x = speed;
_xscale = 100;
_root.guy.gotoAndStop(2);
}else if (Key.isDown(Key.LEFT)) {
_x -= speed;
_xscale = -100;
_root.guy.gotoAndStop(2);
}else{
_root.guy.gotoAndStop(1);
}
}

 
Comment by Daniel
2007-01-06 00:57:57

Awesty, i emailed you twice on both your emails, an you never reply. Can you please post a comment or something then?

 
Comment by awesty
2007-01-06 11:59:39

I just replied to all the emails in my gmail inbox.

 
Comment by Daniel
2007-01-07 06:41:41

Ok thanks, one problem though, i still never got your email.

 
Comment by Daniel
2007-01-07 07:22:37

My ‘man’ gets dragged to the platforms against my will, and when he stands on them he bounces up and down. What can this be cause by?

 
Comment by awesty
2007-01-07 08:51:57

Can you just send it again?

I just checked my sent box and its in there, so maybe it just took a while to get to your inbox?

 
Comment by Daniel
2007-01-07 09:03:23

Ok ill try. Thanks

 
Comment by Daniel
2007-01-07 10:01:05

Yay i got your email ! :D
Tyvm

 
Comment by Daniel
2007-01-09 11:58:32

In the email you sent me and the tut i did, in both of them whenever your character is standing under a platform and jumps, he gets dragged to the platform above him and just hangs in the air somewhere between the botttom and the top platform.

Please help.

 
Comment by awesty
2007-01-13 15:55:22

Can you please send the .fla to me again then?

 
Comment by Daniel
2007-01-14 11:13:42

Yea, thanks.

 
Comment by flable
2007-01-15 02:33:56

Dude, my guy just keeps falling and thats not fun at all. I cant get the ground to work.

 
Comment by awesty
2007-01-15 14:36:37

You can email it to:

awestyproductions[@]gmail[.]com.

If you want. I will try and fix it.

 
Comment by Brandon
2007-01-28 14:42:49

Hi,

I have a couple questions.

Firstly, I notice that my character (in this case a ball) is shaking. I was wondering if there is a way to fix that?

Secondly, because my ground is surrounded by the blue box created by converting it to a Movie Clip,
my character no longer falls to its exact line. Is there any way around this?

Thank you,
Brandon

 
Comment by awesty
2007-01-28 19:12:45

Ah… make sure your lines arent really thin.

 
Comment by CHOCOLATE THUNDER!
2007-01-29 07:51:52

ummm well i typed everything in and i got two errors did i do something wrong?

**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 27: Statement must appear within on/onClipEvent handler
if(jump

 
Comment by awesty
2007-01-29 08:42:03

Your comment got cut off. You cant use the less than sign. ( < )

 
Comment by Bob
2007-02-01 07:27:01

Why is my guy bouncing?

 
Comment by awesty
2007-02-01 21:03:00

Its just a fault in the code, it can be fixed by making a few tweaks. I will upload a better code another time.

 
Comment by Bob
2007-02-02 07:23:25

Oh, ok cool

 
Comment by Lawl
2007-02-13 08:43:50

for all of you guys who cant get this to work heres some help.i use flash mx 2004 and it works fine.

1). Make sure you followed everything and gave the ground/platformjumping things an “instance” name of ground1,2,3,4,…etc.
2). If you copied the code make sure you got rid of all the line numbers. I.E
1. code

2. code

3. code
etc.
———————-
it should work from there

 
Comment by jesse
2007-02-14 11:12:48

why does he rise throung the ground

 
Comment by awesty
2007-02-14 16:19:09

Its just a bug. I am working on a better one ATM, so I will upload that when it is done.

 
Comment by Kurt Subscribed to comments via email
2007-02-15 01:29:12

Well how do you jump?

 
Comment by awesty
2007-02-15 16:14:22

Im not even going to answer that >_>

 
Comment by Kurt Subscribed to comments via email
2007-02-16 07:30:27

Well i didn’t really know because of an error but now i know it is up because of the code i checked.

 
Comment by awesty
2007-02-16 16:04:59

If you read all the explanations you should be able to figure that out. If you dont know, you obviously just copy and pasted the code and hoped it would work.

 
Comment by Kurt Subscribed to comments via email
2007-02-17 10:12:53

well i read it but quickly. but then slowly.

 
Comment by Crzymdget101
2007-02-23 09:32:04

I have this code on my man, and he is suspended in air at start. i have set jump to true at start and falling at seperate times. he wont jump do anything. the only thing that works is the _x movement and tahts because i have the background scroll instead of the character. someone help me out.

onClipEvent (load) {
var jump:Number = 0;
var jumping:Boolean = false;
var falling:Boolean = false;
var g:Number = 3;
}
onClipEvent (enterFrame) {

if (jumping == true || falling == true) {
this._y -= jump;
}
if (jumping == false) {
if (!falling) {
jump = 0;
}
if (Key.isDown(Key.SPACE)) {
jump = 15;
jumping = true;

}
if (jumping == true) {
jump -= 1;
}

if (jump

 
Comment by awesty
2007-02-24 10:23:20

When you post your code in your comments you cant use less than signs.

 
Comment by Maciek
2007-02-27 03:28:29

heh mine guy is vibrating like some kind of a vibrator^^

 
Comment by andy
2007-03-04 01:31:35

the guy just falls through the floor for me do u no how to fix it

 
Comment by awesty
2007-03-05 16:48:19

@Andy: Make sure you didnt miss anything.

 
Comment by RDB2006
2007-03-11 07:28:49

Hi awesty. I took this tutorial ages ago and most of it worked OK. There’s a few things i need to know.

How can i make it more realistic i.e - you can’t fall through the platforms and you can’t drift up onto them/through them when your close. Thanks.

 
Comment by Ben
2007-03-12 01:32:27

Ive used this in my game that im makin at the moment the code sorta works. But the mc shakes when its landed on a bit of ground, and when it lands it goes a bit funny. Any ideas?

Cheers

 
Comment by awesty
2007-03-12 09:44:01

@RDB2006: If you have a look at the second hitTest tutorial, you will find that those hitTests can be alot better to work with.

@Ben: Its just a bug in the script, it can be easily fixed with an if statement somewhere.

 
Comment by akskater100
2007-03-29 07:47:01

where can i get actionscript

 
Comment by awesty
2007-04-05 13:20:46

@akskater100: You need Adobe/Macromedia Flash.

 
Comment by Trunk Monkey
2007-04-28 07:06:59

What does all the ‘If jumping is false’ and ‘If falling is false’ mean?

Comment by awesty
2007-05-01 20:52:45

If the jumping variable is equal to false and if the falling variable is equal to false.

 
 
Comment by zengara Subscribed to comments via email
2007-05-11 03:31:05

Hi thanks a lot.

It works but there is a extrange thing, if you press left or right key the thing pass throug the holes, only if you jump you fall.

By other side don´t try to use this kind of codes in Flash CS3 action script 3.0 I can´t figure out why I can add action scripts to objets only to scenes. It simple doesn´t allow it.

 
Comment by Calum Subscribed to comments via email
2007-05-21 06:06:16

Hi awesty,

I am fiddling about with Sprite Sheets and I have made my sprite turn left when i press left, right when i press right, and it shows my sprite holding a gun when i press CTRL. But what I want now is for it to be able to jump onto lots of different platforms. But when I add your platform jumping code I get a million errors. Please email me the code or what to do. Thanks :) Calum

 
Comment by Calum Subscribed to comments via email
2007-05-21 10:05:28

Oh wait it’s ok I found it out myself :) I cant beive it. about 3 months ago i was a noob at flash but now im gettin really good at it :) Btw if u wanna see my flash ork so far visit http://www.prositedesigner.co.uk/flash/ and email calum1994@hotmail.co.uk to tell me wha you think of it! Thanks

 
Comment by Calum Subscribed to comments via email
2007-05-21 10:07:20

Oh wait it’s ok I found it out myself :) I cant believe it. about 3 months ago i was a noob at flash but now im gettin really good at it :) Btw if u wanna see my flash work so far visit http://www.prositedesigner.co.uk/flash/ and email calum1994@hotmail.co.uk to tell me what you think of it! Thanks

Comment by awesty
2007-07-03 17:27:38

Cool. You have some nice stuff there.

 
 
Comment by Trunk Monkey
2007-05-31 05:30:07

How do you make it so when the amn drops to the bottom of the screen?

And how do you make the screen go along and upwards so I can put in more things in?

And how do you make i so there is a portal to the next lvl?

Comment by awesty
2007-07-03 17:28:20

Open flash, hit F1 and type in hitTest.

 
 
Comment by jebego
2007-06-01 20:57:42

hi, I was wondering how to fix my guy from vibrating like mad.

 
Comment by Trunk Monkey
2007-06-02 09:28:35

Yay I finally completed my first game go to http://www.deviantart.com/deviation/56638897/ to play it

 
Comment by Trunk Monkey
2007-06-04 05:49:04

how come every time i use more than 4 grounds the rest don’t work

Comment by awesty
2007-07-03 17:28:42

No idea.

 
 
Comment by Ricky Shroder
2007-06-06 12:35:48

Because you are a tool.

 
Comment by Trunk Monkey
2007-06-11 01:01:52

I making another platform game and the character animates but how do I make it do a animation when 2 buttons are pushed down

Im using this code to make it animate
if(Key.isDown(Key.UP)){
this._y -= 5;
_root.joe.gotoAndStop(3)
}

Comment by awesty
2007-07-03 17:31:42

if(Key.isDown(Key1) && Key.isDown(Key2)){
//Animation code
}

 
 
Comment by i will Subscribed to comments via email
2007-07-18 03:03:41

Awesty it works fine, kinda, when the ball hits the ground it kinda bounces a little bit, and how would i go about making it so my character can’t go through the bottom of the grounds. thx

 
Comment by Ritto Subscribed to comments via email
2007-07-23 01:23:16

Hey, I’ve been looking for a tutorial that explains this for a long time, and i understand everything. 1 thing tho. Is there a way to make the ground without doing all the different instance names? I tried making ground with no instance name and this action script :
onClipEvent (enterFrame) {
if (this.hitTest(_root.p1)) {
_root.p1._y -= 11;
}

}
It actually worked, but it only lets my character jump once. Lol i couldn’t figure it out. Strange effect…

 
Comment by Ritto Subscribed to comments via email
2007-07-23 05:51:19

Ok, i think i figured out why he vibrates on the platforms. You made the platforms push him up at a rate of 12, but he falls of a rate of 11, so it makes him look like hes bouncing. I’m not sure if this is right, but i know he falls at a rate of 11, cause when i did my code above, he didn’t bounce.

 
Comment by Ritto Subscribed to comments via email
2007-07-23 09:23:04

ok i figured out how to fix the single jump problem. After all the other codes, i typed :
onClipEvent (keyUp) {
jumping = false;

}
It works really well!

 
Comment by Ritto Subscribed to comments via email
2007-07-23 09:28:13

Dang it! that gave me another problem…i can jump in mid air….

 
Comment by Ritto Subscribed to comments via email
2007-07-24 00:16:06

Alright i finally got it! In the ground’s actions wright : _root.p1.jumping = false : inside the “if” command above. Make sure the ground has no instance name. No more vibrating :)

 
Comment by Ritto Subscribed to comments via email
2007-07-24 00:17:22

onClipEvent (enterFrame) {
if (this.hitTest(_root.p1)) {
_root.p1._y -= 11;
_root.p1.jumping = false;
}

}

 
Comment by LDiato Subscribed to comments via email
2007-09-01 08:07:13

Can you delete the left right coding? I have a flash with left right already and only need jump.

Comment by awesty
2007-09-10 17:17:41

If you have already made it than you should know which parts to take out ;)

 
 
Comment by Kurt Subscribed to comments via email
2007-11-06 07:25:55

lol I just tried doing this today and it worked maybe cause I have flash 8 now well I had it for like 7 months already and man I sounded stupid when I was 11 lol.
and I’m going to read the code again it’s been about 9 months since I read it or I might have not read it all before. And one more thing he bounces when he is on a platform it is probably because you try to go up when your on the platform but the gravity you make with the code pulls you down.

 
Comment by Kurt Subscribed to comments via email
2007-11-06 07:34:10

Darn it I needed to edit it once more but once you edit it you can’t edit again I think. Well also when my guy is underneath a platform he floats up maybe because he is tall and hits it but even if he hits it that’s not really good to have in your game I will read the code and try to figure out how to fix it.

Comment by awesty
2007-11-06 09:35:24

It is a bug in the script. I wrote this tutorial ages ago and the script kinda sucks. Try using a point hitTest (hitTest(MC._x,MC._y,true) with the mans feet instead of just a normal hitTest.

I will try and write a better script than this some day.

 
 
Comment by Mat Subscribed to comments via email
2007-11-19 14:16:51

Hey uhhh… for me it works but the problem is that if he goes into the wall sideways, he starts floating up. Lets say this is my wall or grounds:

———–
………..———-

——————————

(the dots arnt anything)

So lets say my guy tries to jump on the first platform, and the top half of his body goes into the platform. He starts floating up. I want to make my game have a chalange in jumping, not touch the wall and stand on it. so can u plz help (also i go up if i made a square and i run into it)

 
Comment by Mat Subscribed to comments via email
2007-11-20 11:38:04

sorry for double posting, but in my adventure game, i want the camra to scroll only on the character. I looked everywer and coundlnt find:
. this is char

, This is nothing (so i could space it

– This is stage

[ ] this is where i want camera to be, when the character mooves, want it to go along with him

,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,[,,.,,]
————————————————————————————————————————————————————-

Comment by Ritto Subscribed to comments via email
2008-03-20 10:02:54

Mat, you need to put all the code in the stage instead of the char. If you put

“if(key.isDown(Key.LEFT))
{this._x (plus)= 1;}”

change the (plus) to a minus & put the code in the stage.
(also, the entire stage has to be a MC)

 
 
Comment by Blaine Subscribed to comments via email
2007-11-25 02:49:30

I can’t get it to work i pasted the code and made instance names for my ground and my man. Could it not be working because I added a hittest for the ground so he doesn’t fall through or what

 
Comment by scott
2007-12-18 02:32:59

when my character is just standing on the ground he is shaking. how can i fix this?

 
Comment by Cecil
2008-01-13 06:12:34

Maaan,how could people get so many errors, all you needed to do at minumum was follow a few directions and copy paste the code.
Great tutorial, very helpful, I will begin trying to understand all of it so I can modify it. You rock, thanks!

Oh yeah, and the same thing is happening to me as scott.

 
Comment by Bryce K Subscribed to comments via email
2008-01-21 09:16:49

how do I make my guy stop vibrating like mad?

 
Comment by rambofx Subscribed to comments via email
2008-09-28 00:46:32

hey i have a jumping problem. Im pretty sure i got the code all right but i can jump in the air once because my guy starts out falling, but when he hits the ground he cant jump anymore.he can still walk but can not jump. I tryed emailing you but it says you cant recieve emails from the comcast server.

 
Comment by toasty Subscribed to comments via email
2009-03-17 18:02:10

When i apply this code my MC bounces on the floor, and is sort of sucked into the ground1 level.

It’s confusing me

 
Name (required)
E-mail (required - never shown publicly)
URI
Subscribe to comments via email
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong> in your comment.