1
votes

I created a sprite that is 18 frames long and it is supposed to be stationary and run through the frames and loop the animation, but when it runs it moves slowly across the screen as it animates until it hits the last frame then jerks back to the original position where it was suppose to stay at.

I don't know the reason it does this and have tried to make it smaller sizes and larger sizes, at some sizes it does not move but just animates likes its supposed to do. If anyone has an answer to why this happens and how to stop it from moving and stay where it is supposed to be it would be greatly appreciated.

I use only 1 row for the sprite and I used gimp to create the sprite and saved it as a png.

1
You should add some code stuff, how you are trying it out.Lalit Poptani

1 Answers

0
votes

The code is rather long thats why I didn't add it but it based on this tutorial aquarium live wallpaper tutorial

I think I found my answer though, I had the png sprite in a folder I created named drawable, where I put all the images, I tried it again but put the sprite in the other folders this time and it didn't move, I tried scaling the sprite also which made it go a bit wonky, I was hoping on using scaling instead so it stayed the same size for all screens, this works for normal images but for sprites it causes some issues, maybe I'll try that with the largest size in the drawable-large-mdpi folder and see if it causes any issues that way. I'll update with that method and let you know. It would be nice to have just one image and scale it instead according to screen size.

Okay I found the answer finally and it might help those creating sprites,the width when divided into the amount frames has to be a whole number since the measurements are in int not float or double, so it moves because when the frame gets divided it came out to a fraction instead which caused it to moves (I guess) whatever that float extra measurement was. Example: if the sprite was 100 pixels high and 1082 px wide and I had 15 frames the width of each frame would then be 72.133333333px wide for each frame causing an error that would move the image that extra length while keeping the animation looking nice. now if it was 1080px wide each frame would then be 72px wide a nice whole number and then would animate perfectly. So for those creating there own sprites make sure the wide equals out to be a whole number when the frames get divided (My problem was I was creating one image scaling it down and not checking the width of each frame so only one image size usually work, sometimes I got lucky and got two, I should of figured this out because it all runs in int not float for measuring the width. Hope this helps out someone else making sprites. Sam