modules/world: put input functions in BaseActor
This commit is contained in:
parent
cd62f9c7d1
commit
6225f1fb4e
2 changed files with 12 additions and 12 deletions
|
@ -36,7 +36,6 @@ function Actor2D:new(world, type, x, y, w, h, isSolid)
|
||||||
self:initPhysics(x, y, w, h, isSolid)
|
self:initPhysics(x, y, w, h, isSolid)
|
||||||
self:register()
|
self:register()
|
||||||
|
|
||||||
self:initKeys()
|
|
||||||
self:initTimers()
|
self:initTimers()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -65,17 +64,6 @@ function Actor2D:setBounceFactor(newBounceFactor)
|
||||||
self.bounceFactor = newBounceFactor or 0
|
self.bounceFactor = newBounceFactor or 0
|
||||||
end
|
end
|
||||||
|
|
||||||
-- INPUT FUNCTIONS
|
|
||||||
-- get input from the world object
|
|
||||||
|
|
||||||
function Actor2D:initKeys()
|
|
||||||
self.keys = core.input.fakekeys
|
|
||||||
end
|
|
||||||
|
|
||||||
function Actor2D:getInput(keys)
|
|
||||||
self.keys = keys or core.input.fakekeys
|
|
||||||
end
|
|
||||||
|
|
||||||
-- TIMER FUNCTIONS
|
-- TIMER FUNCTIONS
|
||||||
-- Control the integrated timers of the actor
|
-- Control the integrated timers of the actor
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ local BaseActor = Object:extend()
|
||||||
function BaseActor:new(world, type)
|
function BaseActor:new(world, type)
|
||||||
self.type = type or ""
|
self.type = type or ""
|
||||||
self:setManagers(world)
|
self:setManagers(world)
|
||||||
|
self:initKeys()
|
||||||
|
|
||||||
self:setDebugColor(1, 1, 1)
|
self:setDebugColor(1, 1, 1)
|
||||||
end
|
end
|
||||||
|
@ -58,4 +59,15 @@ function BaseActor:destroy()
|
||||||
self.isDestroyed = true
|
self.isDestroyed = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- INPUT FUNCTIONS
|
||||||
|
-- get input from the world object
|
||||||
|
|
||||||
|
function BaseActor:initKeys()
|
||||||
|
self.keys = core.input.fakekeys
|
||||||
|
end
|
||||||
|
|
||||||
|
function BaseActor:getInput(keys)
|
||||||
|
self.keys = keys or core.input.fakekeys
|
||||||
|
end
|
||||||
|
|
||||||
return BaseActor
|
return BaseActor
|
||||||
|
|
Loading…
Reference in a new issue