I am writing a phonegap application (using html, css and javascript) and I am stuck in the animation part, although I use simple basic spritesheet animations.
A) I tried to animate BASIC, but I have two problems:
1) If I donโt have a full sprite in the grid, which I may not have, it also displays empty frames, and I donโt know how to skip them, I donโt need to convert the whole sprite to one line. (I heard that you can somehow define each frame, but I really canโt find how to do it, I searched everywhere!)
2) In addition to empty frames, the animation displays well on the desktop, but when I try it on a mobile device, it looks something like this ( http://jsfiddle.net/alecstheone/5pqmsd4a/4/ ), as if the steps and speed are not synchronized . If I try to run jsfiddle inside my mobile browser, everything will display exactly the same as on the desktop.
This is the first code:
HTML:
<div id="container"> <div class="hi"></div> </div>
CSS
.hi { width: 389px; height: 238px; background-image: url("http://i.imgur.com/XOmx2Mm.png"); position: relative; border: solid 1px black; -webkit-animation: playv 1.2s steps(6) infinite, playh 0.2s steps(9) infinite; } #container { } @-webkit-keyframes playv { 0% { background-position-y: 0px; } 100% { background-position-y: -1429px; } } @-webkit-keyframes playh { 0% { background-position-x: 0px; } 100% { background-position-x: -3500px; } }
B) I tried to animate with spritespin.js. It is much easier than before. It calculates all the frames in the spritesheet, so empty frames are not displayed, but it also has two problems (both on the desktop and on the mobile device):
1) The animation looks volatile. I think this is just the thought that this is happening, because the script is trying to calculate the size of each frame and it will go badly. (even if I set the width and height). Can I skip this part? This happens in all rendering methods (background, image, and also canvas, both on mobile and on the desktop).
2) The background size is not calculated correctly. You can see some leftovers at the top of the animation, which should have been at the bottom. Can I resize the background to a few pixels? I use the same sprites in both versions, so I donโt think it is because of the sprite .. or?
This is the second code:
JS:
...... $(".hi").spritespin({ source: "http://i.imgur.com/XOmx2Mm.png",
PLEASE help me solve any way A or B completely! I have been staying on this thing for 3 days, and I'm really tired of it!