feat:make actor able to load sti properties

This commit is contained in:
Kazhnuz 2021-03-20 16:08:10 +01:00
parent 3ab7771352
commit e22a293f03
3 changed files with 11 additions and 4 deletions

View file

@ -45,6 +45,10 @@ function BaseActor:new(world, type, x, y, z, w, h, d, isSolid)
self:register()
end
function BaseActor:setProperties(properties)
-- Do something here
end
function BaseActor:setManagers(world)
self.world = world
self.scene = world.scene

View file

@ -102,10 +102,13 @@ function BaseWorld:initActors( )
self.currentCreationID = 0
end
function BaseWorld:newActor(name, x, y, z)
function BaseWorld:newActor(name, x, y, z, properties)
local debugstring = " at (" .. x .. ";" .. y .. ")."
core.debug:print("world2D", "adding actor " .. name .. debugstring)
self.obj.index[name](self, x, y)
local actor = self.obj.index[name](self, x, y)
if (properties ~= nil) then
actor:setProperties(properties)
end
end
function BaseWorld:newCollision(name, x, y, z, w, h, d)

View file

@ -90,7 +90,7 @@ function StiMap:batchActor(objectlayer, object)
for i=1, cellHor do
for j=1, cellVert do
self.world:newActor(name, x + (i-1)*gwidth, y + (j-1)*gheight, z)
self.world:newActor(name, x + (i-1)*gwidth, y + (j-1)*gheight, z, object.properties)
end
end
end
@ -104,7 +104,7 @@ function StiMap:newActor(objectlayer, object)
y = y + z
end
self.world:newActor(objectlayer.name, object.x, y, z)
self.world:newActor(objectlayer.name, object.x, y, z, object.properties)
end
function StiMap:newCollision(objectlayer, object)