I’m working on a game right now and I’m trying to get a movement script to work properly. The animation for it fudges up when you get lazy with your finger movement(like holding left down and then pressing right to go the other direction). I was just seeing if anybody could help me fix this script. I’m relatively new to actionscript…so yea. Any bit of help would be appreciated.
http://theartistsden.bravehost.com/gangstajoshrpg2.swf
sorry if my code is a bit jumbled. I’ve been trying everything to fix the problem.
/////RPG//////////
onClipEvent (load) {
// Animation for moving right
MovieClip.prototype.move_right = function() {
if ((this._currentFrame<25) && (this._currentFrame>18)) {
} else if (this._currentFrame<20) {
this.gotoAndPlay(20);
}
};
//Animate for moving up
MovieClip.prototype.move_up = function() {
if ((this._currentFrame<19) && (this._currentFrame>13)) {
} else if (this._currentFrame<14) {
this.gotoAndPlay(14);
}
};
//Animating for moving down
MovieClip.prototype.move_down = function() {
if ((this._currentFrame<7) && (this._currentFrame>1)) {
} else if (this._currentFrame<2) {
this.gotoAndPlay(2);
}
};
//Animation for moving left
MovieClip.prototype.move_left = function() {
if ((this._currentFrame<13) && (this._currentFrame>7)) {
} else if (this._currentFrame<8) {
this.gotoAndPlay(8);
}
};
}
onClipEvent (enterFrame) {
//COLLISION WITH LEFT
if (this._x-25<26) {
speed = 0;
//COLLISION WITH RIGHT SIDE OF BLOCK
} else if (((this._x-35)<(_root.block._x+25)) && ((this._y-38.0)<(_root.block._y+25)) && ((this._y+38.0)>(_root.block._y-25))) {
speed = 0;
} else {
speed = 10;
}
//COLLISION WITH TOP
if (this._y-38<39) {
speed_up = 0;
} else {
speed_up = 10;
}
//COLLISIONG WITH RIGHT
if (this._x+25>770) {
speed_right = 0;
} else {
speed_right = 10;
}
//COLLISION WITH BOTTOM
if (this._y+38>562) {
speed_down = 0;
} else {
speed_down = 10;
}
//moving left
if ((Key.isDown(37)) {
this._x -= speed;
}
//moving up
if ((Key.isDown(38)) {
this._y -= speed_up;
}
//moving right
if ((Key.isDown(39)) {
this._x += speed_right;
}
//moving down
if ((Key.isDown(40)) {
this._y += speed_down;
}
}
on (keyPress "<left>left") {
if (Key.isDown(38)) {
} else if (Key.isDown(39)) {
} else if (Key.isDown(40)) {
} else if((Key.isDown(40)==false) &&(Key.isDown(39)==false)&& (Key.isDown(38) ==false)){
this.move_left();
}
}
on (keyPress "Down<down>") {
if (Key.isDown(38)) {
} else if (Key.isDown(39)) {
} else if (Key.isDown(37)) {
} else if((Key.isDown(37)==false) &&(Key.isDown(39)==false)&& (Key.isDown(38) ==false)) {
this.move_down();
}
}
on (keyPress "Up<up>") {
if (Key.isDown(40)) {
} else if (Key.isDown(39)) {
} else if (Key.isDown(37)) {
} else if((Key.isDown(37)==false) &&(Key.isDown(39)==false)&& (Key.isDown(40) ==false)){
this.move_up();
}
}
on (keyPress "<right>Right") {
if (Key.isDown(38)) {
} else if (Key.isDown(40)) {this.gotoAndStop(1);
} else if (Key.isDown(37)) {
} else if((Key.isDown(37)==false) &&(Key.isDown(38)==false)&& (Key.isDown(40) ==false)){
this.move_right();
}
}
onClipEvent (keyUp) {
if ((Key.isDown(37) == false) && (Key.isDown(40) == false)) {
this.gotoAndStop(1);
}
}
</right></up></down></left>