feat(hitbox): add a way to advertise an hitbox as main hitbox
This commit is contained in:
parent
81c7dc7cd4
commit
f68e300019
2 changed files with 7 additions and 0 deletions
|
@ -243,6 +243,7 @@ end
|
||||||
|
|
||||||
function Actor2D:initMainHitbox()
|
function Actor2D:initMainHitbox()
|
||||||
self.mainHitbox = Hitbox(self, self.type, 0, 0, self.w, self.h, self.isSolid)
|
self.mainHitbox = Hitbox(self, self.type, 0, 0, self.w, self.h, self.isSolid)
|
||||||
|
self.mainHitbox:advertiseAsMainHitbox()
|
||||||
end
|
end
|
||||||
|
|
||||||
function Actor2D:addHitbox(name, type, ox, oy, w, h, isSolid)
|
function Actor2D:addHitbox(name, type, ox, oy, w, h, isSolid)
|
||||||
|
|
|
@ -39,10 +39,16 @@ function Hitbox2D:new(owner, type, ox, oy, w, h, isSolid)
|
||||||
self.h = h
|
self.h = h
|
||||||
self.isSolid = isSolid
|
self.isSolid = isSolid
|
||||||
|
|
||||||
|
self.isMainHitBox = false
|
||||||
|
|
||||||
self:setDebugColor(0,0,0)
|
self:setDebugColor(0,0,0)
|
||||||
self:register()
|
self:register()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Hitbox2D:advertiseAsMainHitbox()
|
||||||
|
self.isMainHitBox = true
|
||||||
|
end
|
||||||
|
|
||||||
function Hitbox2D:modify(ox, oy, w, h)
|
function Hitbox2D:modify(ox, oy, w, h)
|
||||||
self.ox = ox
|
self.ox = ox
|
||||||
self.oy = oy
|
self.oy = oy
|
||||||
|
|
Loading…
Reference in a new issue