I got one of the ideas working. I actually tried this this morning but used the pure date instead of the just the time, which did not work.
var d = new Date();
hypeDocument.getElementById("imgcontainer").innerHTML = '<img src="' + '${resourcesFolderName}/test.gif?dummy=' + d.getTime() + '">';
you should also clear the interval when leaving the scene before the animation is complete. also may consider requestAnimationFrame insteadof setInterval
I assume this is better because it works on the natural frame rate of the browser which is what this example is aiming for, so thats why it is better in this case ?..
I tried your coding but the display of the gif seems wrong. Can you please help me to identify where i have gone wrong? Punjabi_Version_2.hype.zip (2.4 MB)
I have attached the gif file where it should be and the hype file.
this line sets the name of the image: imgcontainer.style.backgroundImage = 'url( ${resourcesFolderName}/test_' + ('0' + imageNumber).slice(-2) + '.gif)'
Hi @MarkHunte I have followed your example (test_MHv3) and have it running successfully with my own gif. However the gif I have created I believe is 25 fps, whereas I understand a browsers natural frame rate is 60fps so the gif is playing to fast. Is there a way I could resolve this?
Thanks
Update: I have looked at test_MHv2 and changed the ‘33’ in the last section of code to a higher number (100) and this has slowed the frame rate down to nearly match the original gif.
I’m unsure what this could be related to, but viewing on Firefox and Chrome there is flashing between each frame when playing. All images are set to preload so I am struggling to understand why this is happening?
Firefox experiences this flashing first time when opening the scene, however Chrome it seems to happen when the scene is revisited. Safari is working great throughout.
It is probably a rendering delay and may be due to the size (either file size or dimensions) of the images you are using.
(I’ll take this time to plug that the upcoming Hype v4 does have a sprite sheet feature that can do these animations generally smoothly with the ability to set a custom FPS. You’re welcome to join the beta).
Looking at your example - test_MHv1 when you import your gif it remains in a paused state. How can I achieve this for another gif as it seems to constantly keep looping when import mine.
Thats nothing to do with Hype. The gif was saved with loop off.
Not sure what was used to turn it off or even if I did it, probably not but you can open a gif in something like Preview.app and the save as… a new file. This I think will by default turn the looping off.
var d = new Date(); hypeDocument.getElementById(“imgcontainer”).innerHTML = ‘<img src="’ + ‘${resourcesFolderName}/test.gif?dummy=’ + d.getTime() + ‘">’;
It seems to reload the gif (you see it on the right bottom corner each time the scene is revisited), but it’s not positioned the right way (should be positioned as the coins in the middle.