What's Here?
- Members: 137,219
- Replies: 481,448
- Topics: 75,056
- Snippets: 2,567
- Tutorials: 675
- Total Online: 2,240
- Members: 106
- Guests: 2,134
|
how to add gravity when a person you made jumps so that he falls back down (like Mario). this also includes how to make the person move using the arrow keys.
|
Submitted By: seandude
|
|
|
Rating:
|
|
Views: 115 |
Language: ActionScript
|
|
Last Modified: October 8, 2008 |
Instructions: first you have to make the guy in your game and when you convert him to simple then you want the registration on the bottom middle so that he doesn't float away. this also includes the person moving with the arrow keys.
|
Snippet
onClipEvent(load) {
falling=false;
hitting=false;
gravity=7;
speed=6;
jump=0;
jumping=false;
}
onClipEvent(enterFrame) {
if(!_root.ground.hitTest(this._x, this._y, true) && !jumping) {
_y+=gravity;
gravity=7;
falling=true;
}
if(Key.isDown(Key.SPACE) && jumping==false) {
jumping=true;
luigi.play();
}
if(jumping) {
this.gotoAndStop("jump")
this._y-=jump;
jump-=.5;
if(jump<0) {
falling=true;
}
if(jump<-15) {
jump=-15;
}
}
if(_root.ground.hitTest(this._x, this._y, true) && falling) {
jump=12;
jumping=false;
falling=false;
}
if(Key.isDown(Key.LEFT)) {
_x-=speed;
}
if(Key.isDown(Key.RIGHT)) {
_x+=speed;
}
}
Copy & Paste
|
|
|
Programming
Web Development
Reference Sheets
Bye Bye Ads
Monthly Drawing
Top Contributors
Top 10 Kudos This Month
|