I have a game with continuously moving levels. At the end of each level next level objects are spawned and at the beginning of the next level, the objects of the previous level are destroyed.
But i have serious performance issues. After some 5 levels the game gets ridiculously slow. I have a continuously moving gameLayer in which I insert all layer objects.
Is the performance issue due to the fact that the gameLayer is continuously moving in spite of each level object being dynamically spawned and destroyed? How do I resolve this?
Please help me out here…
Here is a sample code of how I move levels…
[lua]local gameLayer = display.newGroup()
local playerGroup = display.newGroup()
local levelObjects = display.newGroup()
gameLayer:insert(levelObjects)
gameLayer:insert(playerGroup)
local myCircle = display.newCircle(playerGroup, 100, 100, 30 );
physics.addBody( myCircle, { density=3.0, friction=0.5, bounce=0.3 } )
local myRectangle = display.newRect(levelObjects, 0, 300, 480, 20);
physics.addBody( myRectangle, “static”, { density=3.0, friction=0.5, bounce=0.3 } )
local myRectangle = display.newRect(levelObjects, 100, 280, 20, 20);
physics.addBody( myRectangle, “static”, { density=3.0, friction=0.5, bounce=0.3 } )
local function moveLevel()
myCircle.x = myCircle.x + 10
gameLayer.x = gameLayer.x-10
end
Runtime:addEventListener(“enterFrame”, moveLevel)[/lua] [import]uid: 64174 topic_id: 13291 reply_id: 313291[/import]

[import]uid: 64174 topic_id: 13291 reply_id: 48886[/import]