Example
Create and use an Animation
Example 0011: Create and use an Animation
  1. -- Example: Create and use an Animation 
  2.  
  3. function load() 
  4.    -- Set a lovely pink background color. 
  5.    love.graphics.setBackgroundColor(246198222
  6.     
  7.    -- Load the source of the animation. 
  8.    local img = love.graphics.newImage("images/anim-boogie.png"
  9.     
  10.    -- Create an animation with a frame size of 32x32 and 
  11.    -- 0.1s delay betwen each frame. 
  12.    anim = love.graphics.newAnimation(img, 32320.1
  13. end 
  14.  
  15. function update(dt) 
  16.    -- The animation must be updated so it  
  17.    -- knows when to change frames. 
  18.    anim:update(dt) 
  19. end 
  20.  
  21. function draw() 
  22.    -- Draw the animation the center of the screen. 
  23.    love.graphics.draw(anim, 400300011
  24. end 
Copyright © 2006-2008 LÖVE Development Team.