modules/world: put input functions in BaseActor

This commit is contained in:
Kazhnuz 2019-05-05 20:51:26 +02:00
parent cd62f9c7d1
commit 6225f1fb4e
2 changed files with 12 additions and 12 deletions

View File

@ -36,7 +36,6 @@ function Actor2D:new(world, type, x, y, w, h, isSolid)
self:initPhysics(x, y, w, h, isSolid)
self:register()
self:initKeys()
self:initTimers()
end
@ -65,17 +64,6 @@ function Actor2D:setBounceFactor(newBounceFactor)
self.bounceFactor = newBounceFactor or 0
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
-- Control the integrated timers of the actor

View File

@ -30,6 +30,7 @@ local BaseActor = Object:extend()
function BaseActor:new(world, type)
self.type = type or ""
self:setManagers(world)
self:initKeys()
self:setDebugColor(1, 1, 1)
end
@ -58,4 +59,15 @@ function BaseActor:destroy()
self.isDestroyed = true
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