modules/world: better separation of init functions
This commit is contained in:
parent
a4aaa28c24
commit
f30bbc7509
1 changed files with 15 additions and 4 deletions
|
@ -1,15 +1,26 @@
|
|||
local Actor2D = Object:extend()
|
||||
|
||||
function Actor2D:new(world, type, x, y, w, h)
|
||||
self.type = type or ""
|
||||
|
||||
self:setManagers(world)
|
||||
self:initPhysics(x, y, w, h)
|
||||
|
||||
self:initKeys()
|
||||
self:register()
|
||||
end
|
||||
|
||||
function Actor2D:setManagers(world)
|
||||
self.world = world
|
||||
self.scene = world.scene
|
||||
self.obj = world.obj
|
||||
end
|
||||
|
||||
function Actor2D:initPhysics(x, y, w, h)
|
||||
self.x = x or 0
|
||||
self.y = y or 0
|
||||
self.w = w or 0
|
||||
self.h = h or 0
|
||||
self.type = type or ""
|
||||
|
||||
self:initKeys()
|
||||
self:register()
|
||||
end
|
||||
|
||||
function Actor2D:initKeys()
|
||||
|
|
Loading…
Reference in a new issue