-
Character Movement NEED HELP!
Okay, so I have an MC for my char, inside there are 4 frames, one with him facing left(idle), one facing right(idle), one facing left(running MC), and on facing right(running MC).
I have the stop action on all of the frames and on the running movieclips i have these two actions.
Code:
onClipEvent (enterFrame) {
if (!Key.isDown(Key.RIGHT)) {
_root.player.gotoAndStop(1);
}
}
or...
Code:
onClipEvent (enterFrame) {
if (!Key.isDown(Key.LEFT)) {
_root.player.gotoAndStop(2);
}
}
on the MC in the main scene, i have this action.
Code:
onClipEvent (load) {
speed = 15;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.UP)) {
this._y -= speed;
this.gotoAndStop(3);
}
if (Key.isDown(Key.DOWN)) {
this._y += speed;
this.gotoAndStop(4);
}
if (Key.isDown(Key.RIGHT)) {
this._x += speed;
this.gotoAndStop(3);
}
if (Key.isDown(Key.LEFT)) {
this._x -= speed;
this.gotoAndStop(4);
}
}
The problem I have though is that when I press up or down, it goes to the right frame, but the movieclip doesn't play, it plays when i use right or left though... Also, how can I make it so it also plays the animation when you press 2 keys at a time eg. right+left.
-
Senior Member
Maybe you need to check for both keys in running mc:
if (!Key.isDown(Key.RIGHT) && !Key.isDown(Key.UP)) {
-
that didn't change anything but for some reason now the right+up, right+down and the down ones work...
-
Try replacing things like this ...
Code:
if (Key.isDown(Key.UP)) {
this._y -= speed;
this.gotoAndStop(3);
}
... with things like this ...
Code:
if (Key.isDown(Key.UP)&&(this.currentFrame != 3)) {
this._y -= speed;
this.gotoAndStop(3);
}
... and see if that fixes anything
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|