PDA

Click to See Complete Forum and Search --> : Acceleration and Decelleration...



ImEric12
06-15-2002, 09:08 AM
I need to make my hero of my game accelerate when you hit an arrow key, and decellerate when you let off of it.. here is my current movement code:



if (Key.isDown(Key.RIGHT)) {
if (this._x<scrollx) {
this._x += moveSpeed;
} else {
scrollStart = true;
}
} else if (Key.isDown(Key.LEFT)) {
this._x -= moveSpeed;
}
if (Key.isDown(Key.DOWN)) {
this._y += moveSpeed;
} else if (Key.isDown(Key.UP)) {
this._y -= moveSpeed;
}
//No Going off the screen!
if (this.hitTest( _root.left)){
this._x += moveSpeed;
}
if (this.hitTest( _root.bottom)){
this._y -= moveSpeed;
}
if (this.hitTest( _root.top)){
this._y += moveSpeed;
}


the scroll stuff is the screen scrolling. How would I add the accel and deaccell?

magnetos
06-18-2002, 07:55 PM
try

http://board.flashkit.com/board/showthread.php?threadid=328922