Level selector

I got some issues with physics.
 

local function createDisplay() local image = display.newImage( "gameBg1.jpg", centerX, centerY ) scene.view:insert ( image ) local startXpos = 30 for x =1, 40 do local block = display.newImage("blocktest1.png") block:translate( startXpos, 600) scene.view:insert ( block ) startXpos = startXpos + 40 physics.addBody(block, "static", {friction=0.5, bounce=0.3 } ) --local startXpos = 100 local ball = display.newImage("coconut.png") ball:translate(400, 20 ) scene.view:insert (ball) physics.addBody(ball, {density = 0.6, friction = 0.6, bounce= 0.6, radius = 19}) end end

When the ball hit’s the ground, there’s suddenly (almost like a explosion) 20 balls.

 

I’m thinking it might be the code that put’s the ground. 
I wrote that code so I didn’t have to put every single block(ground) in code.

I’m not sure if that will work. Anyone had any experience with that ?

Your do statement should end earlier since you are not creating 40 balls but 40 blocks only.

local function createDisplay() local image = display.newImage( "gameBg1.jpg", centerX, centerY ) scene.view:insert ( image ) local startXpos = 30 for x =1, 40 do local block = display.newImage("blocktest1.png") block:translate( startXpos, 600) scene.view:insert ( block ) startXpos = startXpos + 40 physics.addBody(block, "static", {friction=0.5, bounce=0.3 } ) end \<--------- move here --local startXpos = 100 local ball = display.newImage("coconut.png") ball:translate(400, 20 ) scene.view:insert (ball) physics.addBody(ball, {density = 0.6, friction = 0.6, bounce= 0.6, radius = 19}) end

Good Luck!

burhan

I see.
 Thanks.

What would be the best option to get a ball to move, to follow the ground.

I’m currently looking at : setLinearVelocity

Do you have any tip?