Jump to content

Animating with frames of different size from a Texture Atlas


Recommended Posts

I am running into all sorts of trouble when animating sprites with frames of different dimensions.

I mean like if frame 1 of a walk animation is 30x35 and frame 2 is 38x38, for example, i have a problem keeping the sprite level with the floor. it will either fall through the floor, or be up in the air.

I have tried to set the anchor y point to 1 so that it stays level with the ground, this would be ideal if it worked

I have tried using setSize to try and keep the sprite object's dimensions fixed throughout the animation, not as ideal of a solution but it didnt work anyways.


In my game, which is a platformer type game, I have enemies that check the floor in front of them, and if there is no block, (i.e they are on the edge of a platform) they turn around to avoid falling off. but the animation causes the enemy to hover over ground level. not only does it look ugly but it causes them to go back and forth over and over


I also want the player to be able to duck, shrinking the size of his hitbox to avoid head-level projectiles, but as i said, he just falls through the world.



Link to comment
Share on other sites

It depends on your animations. What I wrote is valid for single animation. For eaxample make all your character frames 64x64, but you can make all your bullet frames 8x8 - just keep frames size within single animation. If you have some strange animation, where some frames have lot of pixels and some only few, you will have to find your way or rearrange it (like making group with multiple small objects ...). Of course, you can also adjust collision box on sprite before you call animation.play(). In this way you can adjust it for player when it starts standing animation or crouching animation.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...