The McLeodGaming forums were permanently closed on April 30th, 2020. You are currently viewing a read-only archive.
View unanswered posts | View active topics It is currently Fri May 15, 2020 5:41 am

Forum rules


IMPORTANT

This Forum is for Flash related questions ONLY! Do not ask questions about spriting, Game Maker, Photoshop, or anything else not related to Flash.



 [ 3 posts ] 
[Resolved] Character Movement 
Author Message
User avatar

Joined: Mon Aug 11, 2008 7:27 am
Posts: 2333
Location: ???
Gender: Male
Okay so, i'm using flash 8 pro, and i'm trying to make the character beable to move and when the key isn't pressed, it will play the still animation. right, left, up, down all has animations, as in more than one frame. But the problem is that the code works fine, no bugs etc, but when i try to walk, the up, left and right running animation won't play and only be the still animation. The down only shows the first frame. What did i do wrong?!!

Code:
onClipEvent(enterFrame){
if(Key.isDown(Key.RIGHT)){
this._x +=12;
this.gotoAndStop ("right");
} else { this.gotoAndStop("still");
}
if(Key.isDown(Key.LEFT)){
this._x -=12;
this.gotoAndStop ("left");
} else { this.gotoAndStop("still");
}
if(Key.isDown(Key.UP)){
this._y -=12;
this.gotoAndStop ("up");
} else { this.gotoAndStop("still");
}
if(Key.isDown(Key.DOWN)){
this._y +=12;
this.gotoAndStop("down");
} else { this.gotoAndStop("still");
}
}

_________________
I think this is my signature or something.


Tue Apr 21, 2009 6:36 am
User avatar

Joined: Mon Aug 11, 2008 6:56 am
Posts: 469
Location: not so superhappy fun fun land....
Shounic wrote:
Okay so, i'm using flash 8 pro, and i'm trying to make the character beable to move and when the key isn't pressed, it will play the still animation. right, left, up, down all has animations, as in more than one frame. But the problem is that the code works fine, no bugs etc, but when i try to walk, the up, left and right running animation won't play and only be the still animation. The down only shows the first frame. What did i do wrong?!!

Code:
onClipEvent(enterFrame){
if(Key.isDown(Key.RIGHT)){
this._x +=12;
this.gotoAndStop ("right");
} else { this.gotoAndStop("still");
}
if(Key.isDown(Key.LEFT)){
this._x -=12;
this.gotoAndStop ("left");
} else { this.gotoAndStop("still");
}
if(Key.isDown(Key.UP)){
this._y -=12;
this.gotoAndStop ("up");
} else { this.gotoAndStop("still");
}
if(Key.isDown(Key.DOWN)){
this._y +=12;
this.gotoAndStop("down");
} else { this.gotoAndStop("still");
}
}

alright, i'll fix it for you.
Code:
onClipEvent(enterFrame) {
if(Key.isDown(Key.RIGHT)){
this._x +=12;
this.gotoAndStop ("right");
}
if(Key.isDown(Key.LEFT)){
this._x -=12;
this.gotoAndStop ("left");
}
if(Key.isDown(Key.UP)){
this._y -=12;
this.gotoAndStop ("up");
}
if(Key.isDown(Key.DOWN)){
this._y +=12;
this.gotoAndStop("down");
}
}
// make the character standing left on frame "stillleft"
onClipEvent (keyUp) {
if (Key.getCode() == Key.LEFT) {
this.gotoAndPlay("stillleft");
}
}
// make the character standing still right on frame "stillright"
onClipEvent (keyUp) {
if (Key.getCode() == Key.RIGHT) {
this.gotoAndPlay("stillright");
}
}
// make the character standing still up on frame "stillup"
onClipEvent (keyUp) {
if (Key.getCode() == Key.UP) {
this.gotoAndPlay("stillup");
}
}
// make the character standing still down on frame "still" which you already have
onClipEvent (keyUp) {
if (Key.getCode() == Key.DOWN) {
this.gotoAndPlay("still");
}
}

hope this helps. :smile:

_________________
Image

ashante08 wrote:
We argue, we try to understand each of our problems, we argue some more, rinse and repeat


Tue Apr 21, 2009 6:34 pm
User avatar

Joined: Mon Aug 11, 2008 7:27 am
Posts: 2333
Location: ???
Gender: Male
YES! It worked! Thanks! A hell looooot! *locks*

_________________
I think this is my signature or something.


Wed Apr 22, 2009 3:44 am
Display posts from previous:  Sort by  
 [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software for PTF.