0 Replies - 1055 Views - Last Post: 08 September 2008 - 04:35 PM

#1 seandude  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 08-August 08

make a person move and add gravity to it.

Posted 08 September 2008 - 04:35 PM

Description: 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. 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.
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;
	}
	
}


Is This A Good Question/Topic? 0
  • +

Page 1 of 1