-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathani.lua
More file actions
30 lines (26 loc) · 698 Bytes
/
ani.lua
File metadata and controls
30 lines (26 loc) · 698 Bytes
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
require "lib/animation"
-- local Class = require("lib.middleclass")
-- ani 动画测试
ani = Class("ani")
function ani:init(img,x,y,w,h,dur)
local w,h,sw,sh,dur,offx,offy
w = w or 192
h = h or 192
dur = dur or 0.05
local path = "assets/graphics/Animations/"..img..".png"
local img = love.graphics.newImage(path)
sw,sh = img:getDimensions()
self.animation = love.graphics.newAnimation(img,1,1,w,h,0,0,sw,sh,dur)
self.animation.mode = 1
self.x = x -80
self.y = y -80
--return self
end
function ani:update(dt)
self.animation:update(dt)
end
function ani:draw(r,sx,sy,offx,offy)
local x,y = self.x,self.y
local animation = self.ani
self.animation:draw(x,y,r,sx,sy,offx,offy)
end