The animation of a sprite sheet goes from frame to device. In the simulator it works perfectly.
I checked it three times, the drawings are perfectly aligned. There is not the problem.
Nor is it in the width and height specifications.
The animation of a sprite sheet goes from frame to device. In the simulator it works perfectly.
I checked it three times, the drawings are perfectly aligned. There is not the problem.
Nor is it in the width and height specifications.
I don’t know what you’re saying here: "The animation of a sprite sheet goes from frame to device. "
Make a demo, zip it up, share it here by attaching zip file to your post (click ‘more reply options’ below).
Also, tell us (using a numbered list as I have).
What you did.
What you expected to see.
What you saw.
Why you think it is wrong.
I made an animation using a spritesheet.
I expected to see the animation.
I see the animation, but the screen coordinates of the animation are not respected.
The coordinates of the frame are not stable.
It is wrong because the x and y coordinates must be stable.
Also, in the simulator this does not happen. It looks perfect.
I’d love to help, but I need code I can run and examine
Please make a demo and share it.
I assume you mean the “Mate” Jitter is the wrong thing?
Please make a demo app with just that animation and share the code.
Question: Did you use a tool to make your spritesheets or are you doing this by hand?
I think we do not understand each other:
First. In the simulator it is perfect. There is no movement in the x or y axis.
Second. It looks bad on the device. An ipad2 Air.
Third. Always, always, the animations I make in Adobe Photoshop. This is irrelevant, since the device looks bad but in the simulator it looks good.
Yes, you’re not understanding my request.
Till you make a tiny demo with the animation I can’t run it and I can’t examine the code, art, etc. so… I can’t help.
I can’t pull an answer out of the air. I need to see what you are doing in a working example I can run and debug.
Here I send what they asked me.
Thanks for the code. I’ve got good and bad news.
The good news is it works perfectly for me on my device.
I built it on my Windows machine using Corona 2018.3363. I then installed it on my Galaxy Tab 4 device running Android 4.4.2 for testing.
The animation played flawlessly without jitter in the simulator and on the device.
(Note: To make this easier to verify, I made the animation loop forever. This way I didn’t have to reload the app over and over to test it. However, even without that change, there was no jitter.)
You can download my APK here if you want to test it yourself:
https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2018/10/spritesHelp/animHelp.zip
The bad news is we don’t know yet what is causing you trouble.
I have some questions (I am using a numbered list, please respond with a numbered list so I can correlate answers with questions directly):
Did you build and test this example and verify it reproduced the problem before sharing it above?
Does the APK I built work for you as expected?
If you see an issue, please describe it. I don’t see any issues and I want to be sure I understand it.
(Thus far I understand the problem to be that the sprite frames are jittering in your game or app. That is, the images are shaking side-to-side in your MP4 video.)
What version of Corona are you building with?
What device are you building for and what OS version is it running?
PS - If you want to respond in Spanish, that is OK. I’m willing to translate. I will still respond in English, but I’d like to make this as easy for you to reply as possible.
Like Ed, I wasn’t able to reproduce the jittering that you described, but I may be able to offer some additional suggestions.
Consider the following:
*Edit, improved readability
One Issue I see here is that your image file is WAY too big.
For maximum compatibility, you need to use multiple files where no file has a dimension greater than 2048
*UPDATE* Looks like XeduR @Spyric and I were typing at the same time.
I agree. You can also get rid of the black part of the images unless it serves a purpose.
OK. I took your original example and did this:
I split the image into 60 discrete images.
I got rid of the black background for the most part.
I used texture packer to make a new image sheet with the dimensions 504 x 814
I exported a new sprite image and lua file.
I used this to reproduce your example.
You can download my work here:
https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2018/10/spritesHelp.zip
In that zip file you will find two folders:
Try this and see if it works better.
Note: I would not use it in your app/game because I probably messed up the butterfly, but if this works then you know what to do to fix the issue.
PS - The jiggling in your original code (not the demo code) is probably being caused by this:
Your image gets downscaled so it can be loaded fully into memory.
Because you have odd numbered widths , the frame alignment of some frames get shifted to the nearest pixel.
When Corona goes to show frames, this alignment issue is visible as jiggling left and right.
In the MP4 video you provided it looked like you were zooming in on the animation. So a single pixel left-right offset was getting turned into multiple pixels of offset and the jiggle was highly pronounced.
The large width is the likely culprit, as mentioned above. More specifically this is probably a quirk of floating-point, in particular the narrower variety used by the GPU.
Details, if you’re interested:
In the process of sending your sprite sheet positions along to the graphics hardware, they’ll be normalized to the [0, 1] range, by being divided by the image’s dimensions.
Now, see the “qualifiers” section on page 3 here (OpenGL ES quick reference).
You are only guaranteed (by hardware that honors the spec) to have 2-10 precision, or 1 / 1024ths. If you see that part about “FP Magnitude Range”, all your numbers are formed by interpolating between neighboring powers of 2, in units of 1 / 1024th the distance between them. (Texture coordinates in Corona shaders fall into the mediump category.)
As an example, between 2-1 and 20 (that is, .5 and 1), you have a step size of 1 / 1024 * .5, or 1 / 2048, whereas you need closer to 1 / 8096 to land on a pixel given your width. Thus you get unpredictable results at the edges of your frame unless you pad with several duplicate pixels (filtering will at least mitigate some of this weirdness in the interior). The problem might be less severe the further left you go.
I just tried the project that is in the Mod folder. It works wonders.
I could not test the file with APK extension since it works on Android.
Now I’m going to try removing the black background from the png file, since I have the file in Adobe Photoshop in layers.
I’m going to use my code, since it’s smaller, simpler.
Thanks to everyone who helped me.
Very good explanation StarCrunch.
I don’t know what you’re saying here: "The animation of a sprite sheet goes from frame to device. "
Make a demo, zip it up, share it here by attaching zip file to your post (click ‘more reply options’ below).
Also, tell us (using a numbered list as I have).
What you did.
What you expected to see.
What you saw.
Why you think it is wrong.
I made an animation using a spritesheet.
I expected to see the animation.
I see the animation, but the screen coordinates of the animation are not respected.
The coordinates of the frame are not stable.
It is wrong because the x and y coordinates must be stable.
Also, in the simulator this does not happen. It looks perfect.
I’d love to help, but I need code I can run and examine
Please make a demo and share it.
I assume you mean the “Mate” Jitter is the wrong thing?
Please make a demo app with just that animation and share the code.
Question: Did you use a tool to make your spritesheets or are you doing this by hand?
I think we do not understand each other:
First. In the simulator it is perfect. There is no movement in the x or y axis.
Second. It looks bad on the device. An ipad2 Air.
Third. Always, always, the animations I make in Adobe Photoshop. This is irrelevant, since the device looks bad but in the simulator it looks good.
Yes, you’re not understanding my request.
Till you make a tiny demo with the animation I can’t run it and I can’t examine the code, art, etc. so… I can’t help.
I can’t pull an answer out of the air. I need to see what you are doing in a working example I can run and debug.
Here I send what they asked me.