Moving level

How do you code for a level to be moving(horizontal) such as in mega jump. And in such a level how is the background set and objects placed further along the path ? [import]uid: 23546 topic_id: 12545 reply_id: 312545[/import]

Typically you would use a scrolling background (tutorials on http://Techority.com or check out the code in SampleCode) and then spawn objects as the character moves along - otherwise you’d have countless objects thousands of pixels off the screen and hurt performance. [import]uid: 52491 topic_id: 12545 reply_id: 45893[/import]

That does it. Thank You! [import]uid: 23546 topic_id: 12545 reply_id: 45922[/import]

@Peach

I have a game with continuously moving levels. At the end of each level next level is 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?

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: 12545 reply_id: 48651[/import]

Posted it here…

http://developer.anscamobile.com/forum/2011/08/04/performance-issues-game-0

Awaiting a good solution from someone!
[Hopefully Peach, once she returns from her birthday bashes! :)]

EDIT : Never mind… solved it :slight_smile: [import]uid: 64174 topic_id: 12545 reply_id: 48899[/import]