-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathknockdown.lua
44 lines (38 loc) · 944 Bytes
/
knockdown.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
44
local state = require "state"
local knockdown = {}
setmetatable(knockdown,knockdown)
knockdown.__index = state
function knockdown:__call(c1,c2,length)
local nt = state(c1,c2,{},{},{},{})
nt.length = length
setmetatable(nt,{__index = knockdown})
return nt
end
function knockdown:update()
self.length = self.length - 1
if self.length <= 0 then
self.c1:setState(self.c1.standing)
end
end
function knockdown:acquireBoxes()
self.collisionboxValues = self.c1.knockupCollisionboxes
end
function knockdown:flipBoxes()
state.flipBoxes(self)
if not self.c1.lookingRight then
for k,v in ipairs(self.collisionboxes) do
v:setX(v.x + self:getWidth())
end
for k,v in ipairs(self.hurtboxes) do
v:setX(v.x + self:getWidth())
end
else
for k,v in ipairs(self.collisionboxes) do
v:setX(v.x - self:getWidth())
end
for k,v in ipairs(self.collisionboxes) do
v:setX(v.x - self:getWidth())
end
end
end
return knockdown