Platform Jumping
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.
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.















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
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!
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
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.
awesty you have so much extra code for the ground and all i want to know how to do is jump…help me plz
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
Well you have to put a platform below it lol.
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.
thanks joey
I’ll check and see
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.
can someone put what im suppose to put without explaining parts, ive read its just its getting annoying taking it out :p
webber are you a complete idiot take it out yourself dont be a lazy bitch
y are you so lazy do it your self
bcz i did and it didnt work so i screwed something up and i dont understand the error box
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.
i did but i didnt understand
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
and ofcourse the platforms should be MC?
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
MC = Movieclip
Anything that follows // and doesn’t look like code get rid of. I can’t make it any clearer.
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
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…
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.
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?
Er my comment got botched. The last line should’ve ready “Maybe you can use <pre> tags around your code samples
Yea, i did but then the comments ran to long and off the page
Is this for flash 8?
i doesnt work for me. i just got flash and i dont know a thing. HELP PLEEZE!
wow… i never thought there could be a tutorial so great! thanx! gave me good stuff in my “maze” game!
what comes after ground4?
@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
how do u make a menu and a button that will activate the flash game?
http://www.awestyproductions.c.....-in-flash/
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
Well that doesn’t really help me to help you.
Just calm down and send the .fla to admin[@]awestyproductions[.]com.
lol sry i was kidding i just couldnt ghet it 2 work but its ok i was just kidding
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 :))
my guy just keeps falling through the blocks
but there aren’t any error messages
please help!
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.
@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.
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!!!
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.
}
dangit i cant go any farther lol (sry i took up so much space ill e-mail my script to you)
@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 && this.hitTest(_root[”ground” 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…
if(this.hitTest(_root[”ground” i])){ //if this hits any of the grounds…
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 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
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
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.
@Bryce K: I got your email and deleted your 2 other posts since they took up a far bit of scrolling space.
I will try and fix it when I have time.
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.
Just add one of theses, }, to the end of your code. It should work.
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?
Yep. My email it admin[@]awestyproductions[.]com.
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?
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.
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)
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
@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
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!
it wont let me send it to u
I send mine to you a 10 days ago. Are you going to email back or are you going to post a comment?
@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.
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?
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.
Mohit
You need to change the ” around ground. When you do it properly it turns into green.
@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.
yah awesty i e-mailed u like 3 weeks ago >.> and i never got a response…
Hmm… I can remember emailing you back. Thats weird. I have the message in my sent box.
o.. could u post it cause i guess my e-mail is screwed up
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 && this.hitTest(_root[”ground” i])){
if(jumping == true){
jump -= 1;
}
if(jump <= -10){
jump = -10;
}
for(i=0;i
}
if(!jumping && !this.hitTest(_root[”ground” i]) && !falling){
if(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
falling = true;
this._y -= 1;
}
if(falling == true){
for(i=0;i
falling = false;
}
}
jump -= 1;
}
}
}
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]
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
(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
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
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.
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 -_-
You can email it to:
awestyproductions[@]gmail[.]com
If you want. I will try and fix it.
Thanx man it looks sick now
No problem.
I need help please? how can i make my char jump when i press up?
thnx awesty
Ummm, read the tutorial.
i did but it wont work…
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?
@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.
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
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
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
hey he jumps to high, can anybody help or highlight the code that tells him how high he jumps?
@RDB2006 - thanks for the advice.
@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;
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
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
the code aint working agin just put it all up so i can paist it without the // crap
well awsome tutorial man.
@easy: For head over view, you could just animate it.
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
It got cut off. Email the .fla to:
awestyproductions[@]gmail[.]com.
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.
@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.
Yea, just send it to:
awestyproductions[@]gmail[.]com
hey next tut you make make loco roco ror the psp in flash
ebulp that would be soooo hard. But i heard sony made loco roco in flash. Cuz the graphics look so flashy.
@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.
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
Umm… i have no idea what you said then, but my email is
awestyproductions[@]gmail[.]com
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.
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??
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.
@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.
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
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.
cool? can you send me the link?
@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.
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.
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);
}
}
Awesty, i emailed you twice on both your emails, an you never reply. Can you please post a comment or something then?
I just replied to all the emails in my gmail inbox.
Ok thanks, one problem though, i still never got your email.
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?
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?
Ok ill try. Thanks
Yay i got your email !
Tyvm
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.
Can you please send the .fla to me again then?
Yea, thanks.
Dude, my guy just keeps falling and thats not fun at all. I cant get the ground to work.
You can email it to:
awestyproductions[@]gmail[.]com.
If you want. I will try and fix it.
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
Ah… make sure your lines arent really thin.
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
Your comment got cut off. You cant use the less than sign. ( < )
Why is my guy bouncing?
Its just a fault in the code, it can be fixed by making a few tweaks. I will upload a better code another time.
Oh, ok cool
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
why does he rise throung the ground
Its just a bug. I am working on a better one ATM, so I will upload that when it is done.
Well how do you jump?
Im not even going to answer that >_>
Well i didn’t really know because of an error but now i know it is up because of the code i checked.
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.
well i read it but quickly. but then slowly.
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
When you post your code in your comments you cant use less than signs.
heh mine guy is vibrating like some kind of a vibrator^^
the guy just falls through the floor for me do u no how to fix it
@Andy: Make sure you didnt miss anything.
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.
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
@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.
where can i get actionscript
@akskater100: You need Adobe/Macromedia Flash.
What does all the ‘If jumping is false’ and ‘If falling is false’ mean?
If the jumping variable is equal to false and if the falling variable is equal to false.
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.
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
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
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
Cool. You have some nice stuff there.
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?
Open flash, hit F1 and type in hitTest.
hi, I was wondering how to fix my guy from vibrating like mad.
Yay I finally completed my first game go to http://www.deviantart.com/deviation/56638897/ to play it
how come every time i use more than 4 grounds the rest don’t work
No idea.
Because you are a tool.
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)
}
if(Key.isDown(Key1) && Key.isDown(Key2)){
//Animation code
}
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
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…
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.
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!
Dang it! that gave me another problem…i can jump in mid air….
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
onClipEvent (enterFrame) {
if (this.hitTest(_root.p1)) {
_root.p1._y -= 11;
_root.p1.jumping = false;
}
}
Can you delete the left right coding? I have a flash with left right already and only need jump.
If you have already made it than you should know which parts to take out
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.
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.
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.
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)
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
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,[,,.,,]
————————————————————————————————————————————————————-
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)
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
when my character is just standing on the ground he is shaking. how can i fix this?
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.
how do I make my guy stop vibrating like mad?
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.
When i apply this code my MC bounces on the floor, and is sort of sucked into the ground1 level.
It’s confusing me