PDA

View Full Version : gravity / falling code?



Ravmaster
December 24th, 2006, 10:01 AM
ActionScript Code:

stop();
speed = 3
onEnterFrame = function () {
if(Key.isDown(Key.RIGHT)){
play();
_root.p1._x+=speed
}
else if(Key.isDown(Key.UP)){
gotoAndPlay(37)
}

else(gotoAndPlay(24))
}





im using that code i made, the running works well, but the jumping (the middle part) doesnt seem to work, im pretty sure there isnt a (Key.isPressed(Key.UP)) so that wont work

i also need a gravity code (which im not very good at) and im currently working on another way of working around this script...

if you need to look at the .fla just ask, if anyone could tell me if anything is wrong with the above code, or give me a better one that would be great :link:

EDIT - i also tried adding sliding but alas that didnt go well...

bombsledder
December 24th, 2006, 12:00 PM
well your code is wrong, ill rewrite it for you, and when you have else() // thats declaring else as a function and searching for the function else, in which case you dont have one..




stop();
speed = 3
onEnterFrame = function () {
if(Key.isDown(Key.RIGHT)){
this.play();
_root.p1._x+=speed
}else if(Key.isDown(Key.UP)){
this.gotoAndPlay(37)
}else{
this.gotoAndPlay(24)
}
}



just made sure the syntax was correct

Ravmaster
December 24th, 2006, 02:29 PM
i tried replacing my code with yours, bombsledder but i get the same thing to happen

links to .fla [1.06 MB] (password kirupa :D) [link] (http://www.uploading.com/files/AP8TA3NE/MG___Chocobo_Racing.fla.html) :link: