improvement: lazyload sti objects
This commit is contained in:
parent
fe467119d2
commit
4e4afd2baf
2 changed files with 12 additions and 1 deletions
|
@ -25,7 +25,7 @@ function TiledMap:getDimensions()
|
|||
end
|
||||
|
||||
function TiledMap:loadObjects()
|
||||
self.wrapper:loadObjects()
|
||||
--self.wrapper:loadObjects()
|
||||
end
|
||||
|
||||
-- TILE FUNCTIONS
|
||||
|
|
|
@ -8,6 +8,7 @@ function StiWrapper:new(owner, mapfile, x, y)
|
|||
self.y = y or 0
|
||||
|
||||
self.objectlayer = 0
|
||||
self.isLoaded = false
|
||||
end
|
||||
|
||||
function StiWrapper:getDimensions()
|
||||
|
@ -22,12 +23,20 @@ function StiWrapper:resize(w, h)
|
|||
end
|
||||
|
||||
function StiWrapper:update(dt)
|
||||
self:lazyLoad()
|
||||
self.sti:update(dt)
|
||||
end
|
||||
|
||||
-- OBJECT FUNCTIONS
|
||||
-- Handle objets
|
||||
|
||||
function StiWrapper:lazyLoad()
|
||||
if (not self.isLoaded) then
|
||||
self:loadObjects()
|
||||
self.isLoaded = true
|
||||
end
|
||||
end
|
||||
|
||||
function StiWrapper:loadObjects()
|
||||
self:loadCollisions()
|
||||
self:loadPlayers()
|
||||
|
@ -179,6 +188,7 @@ end
|
|||
-- Draw the map
|
||||
|
||||
function StiWrapper:drawUpperLayers()
|
||||
self:lazyLoad()
|
||||
if (self.objectlayer > 0) then
|
||||
for i = self.objectlayer, self.nbrLayer, 1 do
|
||||
self:drawLayer(i)
|
||||
|
@ -187,6 +197,7 @@ function StiWrapper:drawUpperLayers()
|
|||
end
|
||||
|
||||
function StiWrapper:drawLowerLayers()
|
||||
self:lazyLoad()
|
||||
for i = 1, self.objectlayer, 1 do
|
||||
self:drawLayer(i)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue