Type
Animation
Remember that Animations must be updated each frame. (See example)
Functions
addFrame( x, y, w, h, delay ) Adds a single frame to the Animation.
setMode( mode ) Sets the animation mode.
play( ) Starts the Animation.
stop( ) Stops the Animation
reset( ) Sets the current frame to the first frame and resets timer.
seek( frame ) Sets the current frame.
getCurrentFrame( ) Gets the current frame number
getSize( ) Gets the number of frames.
setDelay( frame, delay ) Sets the delay of a specific frame.
setSpeed( speed ) Sets the overall speed of the Animation.
getSpeed( ) Returns the current speed of the Animation.
getWidth( ) Gets the width of the current frame.
getHeight( ) Gets the height of the current frame.
setCenter( x, y ) Changes the center of the Animation.
update( dt ) Updates the Animation
Examples
Example 11: 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.