Skip to main content
Known Participant
March 3, 2018
Answered

Why does my player character grow in size when moving sideways ?

  • March 3, 2018
  • 1 reply
  • 831 views

Hey,

I'm creating a small game for an assignment. I've created it, and now i'm adding the graphical and animation parts to it. My main character is a bird, and I wanted to add some simple animation to it, and I managed to do it, however, when moving left/right, the character grows in size and I'm not sure why. I've made a video to showcase what's happening. Game animation and hitbox bug - YouTube

Does anyone know how I can fix this? The way I did it was by creating 2 symbols, one for idle, one for running, but the animation in both is the same, then given then names, and called them when certain actions are done in the game to change the animation state. The hitboxes also seem a bit broken with this character 😕😕

This topic has been closed for replies.
Correct answer kglad

Ah I see, fair enough.

Do you know if there is any other ways of doing the animation? As the way I've done it now is gone inside the player symbol, and in there, created two separate symbols called "Player Animation Idle" and "Player Animation Running", and inside those symbols I did the animation itself, but it's the same in both since I just want flapping wings. Is this the usual way to do it or is there another way, which may perhaps solve it?


one way to do that would be to create a bird movieclip and create one or more keyframes in that (bird) movieclip.  one bird keyframe might be a resting bird.  that might even be a movieclip of a bird that periodically scratches his head.  one keyframe might contain a movieclip of a bird with flapping wings.

you would use bird.gotoAndStop() to control which keyframe (resting or flying) is displayed.

1 reply

kglad
Community Expert
Community Expert
March 3, 2018

if you're using code to control your bird your scaleX property should be 1 or -1.

if you're using the time, check the transform panel with your bird selected on all the keyframes.

xKetjowAuthor
Known Participant
March 4, 2018

I've checked my code, and this is what I have:

if(leftPressed){ //If the left key is pressed

xSpeed -= speedConstant; //xSpeed = xSpeed variable - speedConstant variable

player.scaleX = -1; //Makes the player face the left side

} else if(rightPressed){ //If the right key is pressed

xSpeed += speedConstant; //xSpeed = xSpeed variable + speedConstant variable

player.scaleX = 1; //Makes the player face the right side

}

It seems correct to me, and I don't have any other code relating to player scaleX.

I've also checked the transform tab, and I don't exactly know what i'm looking for. It's the same for both when the player stands still and moves, and when I actually play the animation from the place where I created it, it works fine, but it's just in the game where it becomes wider than it should be.

kglad
Community Expert
Community Expert
March 4, 2018

click the transform tool and then select your bird.  make sure the circle (transform point) is in the horizontal center of your bird.