-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathe0011.lua
43 lines (34 loc) · 1.13 KB
/
e0011.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
-- Example: Create and use an Animation
love.filesystem.load("animation.lua")()
function newImagePO2(filename)
local source = love.image.newImageData(filename)
local w, h = source:getWidth(), source:getHeight()
-- Find closest power-of-two.
local wp = math.pow(2, math.ceil(math.log(w)/math.log(2)))
local hp = math.pow(2, math.ceil(math.log(h)/math.log(2)))
-- Only pad if needed:
if wp ~= w or hp ~= h then
local padded = love.image.newImageData(wp, hp)
padded:paste(source, 0, 0)
return love.graphics.newImage(padded)
end
return love.graphics.newImage(source)
end
function love.load()
-- Set a lovely pink background color.
love.graphics.setBackgroundColor(246, 198, 222)
-- Load the source of the animation.
img = newImagePO2("images/anim-boogie.png")
-- Create an animation with a frame size of 32x32 and
-- 0.1s delay betwen each frame.
animation1 = newAnimation(img, 32, 32, 0.1, 6)
end
function love.update(dt)
-- The animation must be updated so it
-- knows when to change frames.
animation1:update(dt)
end
function love.draw()
-- Draw the animation the center of the screen.
animation1:draw(400, 300, 0, 1, 1)
end