Copy link to clipboard
Copied
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 😕
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
click the transform tool and then select your bird. make sure the circle (transform point) is in the horizontal center of your bird.
Copy link to clipboard
Copied
I think this is what you mean https://imgur.com/gallery/dvImX
I've checked it at all of the keyframes, and the circle is in the horizontal middle in all of them 😕
Copy link to clipboard
Copied
don't see a problem there.
you could also be scaling a parent of the bird and that would cause a problem. but i don't think this is going to be remedied via a forum. someone will probably need to download your file to debug it.
Copy link to clipboard
Copied
Would you be able to take a look if I uploaded it somewhere?
Copy link to clipboard
Copied
i only download and correct files if i'm hired.
if you're patient, others may do that for free.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
I've managed to fix it, I completely reset it to the character I had before, removed everything to do with it, removed the code for animation states I had, did the animation the way you said to do it in the previous post and it works!
The only problem i'm seeing is that the hitboxes between the player and obstacles aren't exactly amazing, but it's playable and possible to finish all three levels.
Thanks a lot
Copy link to clipboard
Copied
you're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now