How to animate all sprite images?

user4873951

How to do you animate all image sprite when you have a choosen image sprite does not contain one line images?

**This one example here has a one line image **

Link : Reference

.hi {
    width: 50px;
    height: 72px;
    background-image: url("http://s.cdpn.io/79/sprite-steps.png");
    
    -webkit-animation: play .8s steps(10) infinite;
       -moz-animation: play .8s steps(10) infinite;
        -ms-animation: play .8s steps(10) infinite;
         -o-animation: play .8s steps(10) infinite;
            animation: play .8s steps(10) infinite;
}

@-webkit-keyframes play {
   from { background-position:    0px; }
     to { background-position: -500px; }
}

@-moz-keyframes play {
   from { background-position:    0px; }
     to { background-position: -500px; }
}

@-ms-keyframes play {
   from { background-position:    0px; }
     to { background-position: -500px; }
}

@-o-keyframes play {
   from { background-position:    0px; }
     to { background-position: -500px; }
}

@keyframes play {
   from { background-position:    0px; }
     to { background-position: -500px; }
}
<img src="http://s.cdpn.io/79/sprite-steps.png" />
<div class="hi"></div>

Now this example contains sprite images that is not one line. But contains 3 rows of sprite images. How do you animate this like the link the code snippet above? Do I use jquery/javascript in displaying it? Please help.

img {display: block;margin: auto;}

.sample {
    margin: 0 auto;
    width: 75px;
    height: 100px;
    background-image: url("https://fermmm.files.wordpress.com/2011/02/preview.jpg");
            animation: play 1s steps(4) infinite;
}
@keyframes play {
   from { background-position:    0px; }
     to { background-position: -299px; }
}
<img src="https://fermmm.files.wordpress.com/2011/02/preview.jpg" />

<div style="text-align:center;">Sprite image</div>
<div class="sample"></div>

pblyt

Two separate keyframe animations are created to traverse 4 frames horizontally and 3 frames vertically. When one direction animation is in play, the other one must be frozen.

Since 1s is set to go through 4 horizontal frame, so the next vertical frame would start 1s later, and therefore duration of vertical direction equals to 1s x 3 vertical frames.

img {
  display: block;
  margin: auto;
}

.sample {
  margin: 0 auto;
  width: 75px;
  height: 100px;
  background-image: url("https://fermmm.files.wordpress.com/2011/02/preview.jpg");
  animation: playh 1s steps(4) infinite, playv 3s steps(3) infinite;
}

@keyframes playv {
  0% { background-position-y: 0px; }
  100% { background-position-y: -301px; }
}

@keyframes playh {
  0% { background-position-x: 0px; }
  100% { background-position-x: -299px; }
}
<img src="https://fermmm.files.wordpress.com/2011/02/preview.jpg" />

<div style="text-align:center;">Sprite image</div>
<div class="sample"></div>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Swift - How to animate Images?

From Dev

how to animate diff images in xna game?

From Dev

How to animate different size of images in iOS7 SpriteKit?

From Dev

How to correctly animate images in a data structure and not get ConcurrentModificationException

From Dev

How to make buttons in sprite kit scenes animate as buttons (from view controller)?

From Dev

android- How to animate between view flipper change images

From Dev

How to enumerate ALL nodes in a Sprite Kit scene?

From Dev

how to get images defined in loaded sprite sheet asset with Pixijs

From Dev

WatchKit: How to animate Images stored in Nsmutablearray dynamically in objC

From Dev

Images tremble on animate

From Dev

How to Animate Images while converting to Video

From Dev

How to import multiple images as one sprite in Createjs EaselJS?

From Dev

Canvas animate images rotation

From Dev

Animate SVG images

From Dev

How to animate images onslide of ViewPager?

From Dev

How to turn all embedded images into linked images

From Dev

How to animate different size of images in iOS7 SpriteKit?

From Dev

How to rename all the images in the directory

From Dev

How to correctly animate images in a data structure and not get ConcurrentModificationException

From Dev

SDL How to animate a Sprite when key is pressed

From Dev

SDWebImage animate images

From Dev

how to get images defined in loaded sprite sheet asset with Pixijs

From Dev

How do i animate images in a cyclic manner?`

From Dev

My sprite images is not showing?

From Dev

How to not stack but animate all the way to the right

From Dev

How to animate through an array of CGPoints in Sprite Kit - Swift

From Dev

Canvas - How do you animate multiple images at once?

From Dev

LWJGL—How to Animate and Render Characters Using a Sprite Sheet

From Dev

Cocos Creator js animate sprite

Related Related

  1. 1

    Swift - How to animate Images?

  2. 2

    how to animate diff images in xna game?

  3. 3

    How to animate different size of images in iOS7 SpriteKit?

  4. 4

    How to correctly animate images in a data structure and not get ConcurrentModificationException

  5. 5

    How to make buttons in sprite kit scenes animate as buttons (from view controller)?

  6. 6

    android- How to animate between view flipper change images

  7. 7

    How to enumerate ALL nodes in a Sprite Kit scene?

  8. 8

    how to get images defined in loaded sprite sheet asset with Pixijs

  9. 9

    WatchKit: How to animate Images stored in Nsmutablearray dynamically in objC

  10. 10

    Images tremble on animate

  11. 11

    How to Animate Images while converting to Video

  12. 12

    How to import multiple images as one sprite in Createjs EaselJS?

  13. 13

    Canvas animate images rotation

  14. 14

    Animate SVG images

  15. 15

    How to animate images onslide of ViewPager?

  16. 16

    How to turn all embedded images into linked images

  17. 17

    How to animate different size of images in iOS7 SpriteKit?

  18. 18

    How to rename all the images in the directory

  19. 19

    How to correctly animate images in a data structure and not get ConcurrentModificationException

  20. 20

    SDL How to animate a Sprite when key is pressed

  21. 21

    SDWebImage animate images

  22. 22

    how to get images defined in loaded sprite sheet asset with Pixijs

  23. 23

    How do i animate images in a cyclic manner?`

  24. 24

    My sprite images is not showing?

  25. 25

    How to not stack but animate all the way to the right

  26. 26

    How to animate through an array of CGPoints in Sprite Kit - Swift

  27. 27

    Canvas - How do you animate multiple images at once?

  28. 28

    LWJGL—How to Animate and Render Characters Using a Sprite Sheet

  29. 29

    Cocos Creator js animate sprite

HotTag

Archive