0

How can I make an animation of images?

like a rotating coin in games.

10th Jul 2018, 8:00 AM
Sam
Sam - avatar
12 Answers
14th Jul 2018, 6:17 AM
Sam
Sam - avatar
+ 1
That's really nifty, Mr. Sam! â˜ș Keep up the good work! 👍
14th Jul 2018, 6:59 AM
Janning⭐
Janning⭐ - avatar
0
What kind of animation? You should look up keyframe animations for CSS.
10th Jul 2018, 8:12 AM
James
James - avatar
0
try this -html- <div id="imganimation"></div> -css- #imganimation{ animation-name:imgs; animation-duration:10s; animation-iteration-count:infinite; background-image("https://img1.png"); } @keyframes imgs{ 0%{background-imagr("https://img1.png");} 10% next img and so on
10th Jul 2018, 8:14 AM
Roel
Roel - avatar
0
Is it possible to use Java script?
10th Jul 2018, 8:37 AM
Sam
Sam - avatar
0
Keyframes in CSS is much easier to use than JS, so you should learn it. JS might be useful for some very complex animations though. In JavaScript you can access the CSS and modify it to animate. No matter what, animations are modifying format and format is CSS. You might do something like this... function moveLeft(){ var box = document.getElementById("box"); box.style.left++; } setInterval(moveLeft, 10); Every 10 milliseconds the box element will move one pixel left.
10th Jul 2018, 8:42 AM
James
James - avatar
0
No! By image animation I mean I have a bunch of images and if you put them one after another you get a nice animation. So I need to know how to play them like that. May be we can use arrys...
10th Jul 2018, 8:47 AM
Sam
Sam - avatar
0
Ok, try this. var images = ["1.png", "2.png", "3.png"]; var x = 0; function nextImg(){ var img = document.getElementById("img"); img.src = images[x]; x++; if (x === images.length){ x = 0; } } setInterval(nextImg(), 1000);
10th Jul 2018, 8:52 AM
James
James - avatar
0
sorry your code is not working for me. Can you show the code in action? (by creating a project)
10th Jul 2018, 4:42 PM
Sam
Sam - avatar
0
Hi Mr. Sam, I think James has done plenty of heavy-lifting already. How about you put one of your projects up so we can help troubleshoot your code?
11th Jul 2018, 5:35 AM
Janning⭐
Janning⭐ - avatar
0
I will definitely post my code after learning php.
12th Jul 2018, 4:36 PM
Sam
Sam - avatar
0
Okay. Looking forward. 👍
12th Jul 2018, 6:39 PM
Janning⭐
Janning⭐ - avatar