ForumsProgramming Forum[Flash 8] Sprite's direction changing

4 3958
miksusiili
offline
miksusiili
15 posts
Nomad

[Flash 8] Sprite's direction changing, how this make?
Players Walk LEFT/RIGHT but image dosent direction change.
Can you help?

if walking code help there:

onClipEvent (load) {
var ground:MovieClip = _root.ground;
var grav:Number = 0;
var gravity:Number = 2;
var speed:Number = 7;
var maxJump:Number = -12;
var touchingGround:Boolean = false;
}
onClipEvent (enterFrame) {
_y += grav;
grav += gravity;
while (ground.hitTest(_x, _y, true)) {
_y -= gravity;
grav = 0;
}
if (ground.hitTest(_x, _y+5, true)) {
touchingGround = true;
} else {
touchingGround = false;
}
if (Key.isDown(Key.RIGHT)) {
_width = 26.5;
_x += speed;
play();
}
if (Key.isDown(Key.LEFT)) {
_width = -26.5;
_x -= speed;
play();
}
if (Key.isDown(Key.UP) && touchingGround) {
grav = maxJump;
}
if (ground.hitTest(_x+(_width/2), _y-(_height/2), true)) {
_x -= speed;
}
if (ground.hitTest(_x-(_width/2), _y-(_height/2), true)) {
_x += speed;
}
if (ground.hitTest(_x, _y-(height), true)) {
grav = 3;
}
if(!Key.isDown(Key.LEFT) && !Key.isDown(Key.RIGHT)) {
gotoAndStop(1);
}
}


Walking is three animation sprites.
  • 4 Replies
PixelSmash
offline
PixelSmash
566 posts
Nomad

Hmm, I'd have this function setup a bit more nested, but that's about it - and that's not the problem

Have you tried tracing the _width at the end of the function? You might have to wait a little before all the traces are done (after you close) but those should give you a better understanding. Something else to consider is using scale in stead of width - don't know the exact syntax anymore, I'm used to AS3 by now. Try something like scaleX = -scaleX (which is AS3, but AS2 should be something like it)

Good luck!

miksusiili
offline
miksusiili
15 posts
Nomad

Thanks

_width yeah, me and my friend tried that. But didint work

miksusiili
offline
miksusiili
15 posts
Nomad

That dosent work

scaleX = -scaleX

i using Action Scripti 2

miksusiili
offline
miksusiili
15 posts
Nomad

This problem is clear. I try: this._xscale = 100; and that works!

This topic can locked.

Showing 1-4 of 4