Strike Force Heroes 2
The explosive sequel to the hit game Strike Force Heroes!
3.96 / 5.00 9,743 ViewsObsolescence
Defeat the enormous mechanical beasts--and become one of them.
4.02 / 5.00 45,116 ViewsI really need help i have tried to fix this problem and tried a lot of different solutions but none of them working.
I have this code for my character:
onClipEvent (enterFrame) {
radius = _width/2;
if(Key.isDown(Key.UP)){
this._y -= 10;
this.head.gotoAndStop(3);
this.gotoAndPlay(2);
}
if(!Key.isDown(Key.UP)){
this.gotoAndStop(1);
}
if(Key.isDown(Key.DOWN)){
this._y += 10;
this.head.gotoAndStop(1);
this.gotoAndPlay(2);
}
if(!Key.isDown(Key.DOWN)){
this.gotoAndStop(1);
}
if(Key.isDown(Key.LEFT)){
this._x -= 10;
this.head.gotoAndStop(2);
this.gotoAndPlay(2);
}
if(!Key.isDown(Key.LEFT)){
this.gotoAndStop(1);
}
if(Key.isDown(Key.RIGHT)){
this._x += 10;
this.head.gotoAndStop(4);
this.gotoAndPlay(2);
}
if(!Key.isDown(Key.RIGHT)){
this.gotoAndStop(1);
}
while (_root.wall.hitTest (this._x, this._y+radius, true)){
this._y--;
}
while (_root.wall.hitTest (this._x, this._y-radius, true)){
this._y++;
}
while (_root.wall.hitTest (this._x-radius, this._y, true)){
this._x++;
}
while (_root.wall.hitTest (this._x+radius, this._y, true)){
this._x--;
}
}
I can move the char. around and all that but the walking animation won't play.
Any one help with this problem.
Thanks.
looking at this code certainly takes me back.
do yourself a favor and learn AS3.
Programming stuffs (tutorials and extras)
PM me (instead of MintPaw) if you're confuzzled.
thank Skaren for the sig :P
Your issue is likely that you are telling your clip to gotoAndPlay every frame. A quick fix would be to add labels to your animations, and check if (this.currentLabel != "animationLabelName"). That way it will notice that it's playing the animation, and will not reset it each time.
At 2/6/13 12:31 PM, egg82 wrote: do yourself a favor and learn AS3.
I second this comment.
At 2/6/13 12:36 PM, Mattster wrote: Your issue is likely that you are telling your clip to gotoAndPlay every frame. A quick fix would be to add labels to your animations, and check if (this.currentLabel != "animationLabelName"). That way it will notice that it's playing the animation, and will not reset it each time.
Can't get it to work.
At 2/6/13 01:59 PM, WhaleMan wrote:At 2/6/13 12:36 PM, Mattster wrote: Your issue is likely that you are telling your clip to gotoAndPlay every frame. A quick fix would be to add labels to your animations, and check if (this.currentLabel != "animationLabelName"). That way it will notice that it's playing the animation, and will not reset it each time.Can't get it to work.
Of course, in AS1 there is no currentLabel property, you have to set your own, AS3 already give you that. Another motive which you should change to AS3.
At 2/6/13 02:57 PM, Spysociety wrote:
Of course, in AS1 there is no currentLabel property, you have to set your own, AS3 already give you that. Another motive which you should change to AS3.
I don't want to change to as3 now
At 2/6/13 03:07 PM, WhaleMan wrote: I don't want to change to as3 now
peer pressure says you will.
Programming stuffs (tutorials and extras)
PM me (instead of MintPaw) if you're confuzzled.
thank Skaren for the sig :P
At 2/6/13 11:54 AM, WhaleMan wrote: I really need help i have tried to fix this problem and tried a lot of different solutions but none of them working.
I can move the char. around and all that but the walking animation won't play.
Any one help with this problem.
Thanks.
You need manage the state and fix your key logic. When holding down the an arrow key, it will gotoAndPlay(2) every frame, effectively stopping the animation from ever getting past the first frame. In order to fix this, create a boolean variable to represent whether you are already playing the animation. However, even if you were doing this, the animation would only play when you are holding down the right arrow key because you have a condition that takes the clip back to the first frame if the right key is not down. You could check whether any of the keys are down or just flip another boolean if one is down. Also, instead of checking whether something is false after you just checked if is true, you can use an else statement.
onClipEvent(load)
{
var standing:Boolean = true;
var keysDown:Boolean = false;
}
onClipEvent (enterFrame) {
radius = _width/2;
keysDown = false;
if(Key.isDown(Key.UP)){
keysDown = true;
this._y -= 10;
this.head.gotoAndStop(3);
if (standing){
gotoAndPlay(2);
standing = false;
}
}
if(Key.isDown(Key.DOWN)){
keysDown = true;
this._y += 10;
this.head.gotoAndStop(1);
if (standing){
gotoAndPlay(2);
standing = false;
}
}
if(Key.isDown(Key.LEFT)){
keysDown = true;
this._x -= 10;
this.head.gotoAndStop(2);
if (standing){
gotoAndPlay(2);
standing = false;
}
}
if(Key.isDown(Key.RIGHT)){
keysDown = true;
this._x += 10;
this.head.gotoAndStop(4);
if (standing){
gotoAndPlay(2);
standing = false;
}
}
if (!keysDown)
{
this.gotoAndStop(1);
standing = true;
}
while (_root.wall.hitTest (this._x, this._y+radius, true)){
this._y--;
}
while (_root.wall.hitTest (this._x, this._y-radius, true)){
this._y++;
}
while (_root.wall.hitTest (this._x-radius, this._y, true)){
this._x++;
}
while (_root.wall.hitTest (this._x+radius, this._y, true)){
this._x--;
}
}
At 2/6/13 06:11 PM, Tree-SkyLark-BCE wrote: You need manage the state and fix your key logic. When holding down the an arrow key, it will gotoAndPlay(2) every frame,
Thank you it really helped and got it to work with some tweaks.