zazazayou Posted November 2, 2016 Share Posted November 2, 2016 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. thanks Link to comment Share on other sites More sharing options...
Tom Atom Posted November 3, 2016 Share Posted November 3, 2016 Hi, make all frames of your animation of the same size. Like in this animation: Clever texture atlas tool will trim empty areas automatically, while keeping all necessary info in metadata to position sprite correctly. Then you can play animaton with any anchor you need. Link to comment Share on other sites More sharing options...
zazazayou Posted November 3, 2016 Author Share Posted November 3, 2016 ok but then how would i deal with the smaller pictures that get a bunch of extra space added to their collision box? all the smaller frames will collide before the image actually touches Link to comment Share on other sites More sharing options...
Tom Atom Posted November 4, 2016 Share Posted November 4, 2016 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 More sharing options...
zazazayou Posted November 5, 2016 Author Share Posted November 5, 2016 thanks for the help tom, it worked out when I made all the frames the same size and then adjusted the collision box specially for frames like duck, like you said Link to comment Share on other sites More sharing options...
Recommended Posts