I just recently had a problem with the scene not reloading but with some help it is kinda fixed . The blocks start off in the correct spot but when they come down they appear to be bouncing on nothing .
Level1.lua:
local composer = require( "composer" ) local scene = composer.newScene() local physics = require( "physics" ) physics.start() physics.setGravity(0, 40) local disposeGroup local onBack function scene:create( event ) local sceneGroup = self.view end function scene:willEnter( event ) local sceneGroup = self.view disposeGroup = display.newGroup() sceneGroup:insert( disposeGroup ) background = display.newImage( "background.png" ) background.x = 10; background.y = 308 sceneGroup:insert(background) ground = display.newImage( "ground.png" ) ground.x = 145; ground.y = 480 sceneGroup:insert(ground) ground.myName = "ground" ground.isGround = true physics.addBody( ground, "static" , { friction=0.5, bounce=0.1 } ) myObject = display.newRect( 0, 0, 100, 30 ) myObject.x = 145; myObject.y = 400 sceneGroup:insert(myObject) myObject:setFillColor( 0 ) myObject.isMyObject = true physics.addBody( myObject, "kinematic" , { myObject, friction=0.5, bounce=2 } ) function myObject:touch( event ) if event.phase == "moved" then self.x = event.x self.y = event.y end return true end myObject:addEventListener( "touch", myObject ) wall = display.newImageRect( "wall.png", 600, 300 ) wall.x = -150 wall.y = 250 sceneGroup:insert(wall) wall.rotation = 90 physics.addBody( wall, "static" , { wall, friction=0.5, bounce=0.5 } ) wall2 = display.newImageRect( "wall2.png", 500, 300 ) sceneGroup:insert(wall2) wall2.x = 210 wall2.y = -194 wall.rotation = 90 physics.addBody( wall2, "static" , { wall2, friction=0.5, bounce=0.5 } ) wall3 = display.newImageRect( "wall3.png", 600, 300 ) sceneGroup:insert(wall3) wall3.x = 470 wall3.y = 250 wall3.rotation = 90 physics.addBody( wall3, "static" , { wall3, friction=0.5, bounce=0.5 } ) block = display.newImage( "block.png" ) sceneGroup:insert(block) block.x = 200 block.rotation = 8 block.myName = "block" block.isBlock = true physics.addBody( block, "dynamic" , { block, friction=0.5, bounce=0.5 } ) local function onCollision( self, event ) local other = event.other if( event.phase == "began" and self.isBlock and other.isGround ) then timer.performWithDelay( 30, function() composer.gotoScene ( "restart", "fade", 0 ); end) self:removeEventListener( "collision" ) end return true end block.collision = onCollision block:addEventListener( "collision" ) block2 = display.newImage( "block2.png" ) sceneGroup:insert(block2) block2.x = 100 block2.rotation = 8 block2.isBlock2 = true physics.addBody( block2, "dynamic" , { block2, friction=0.5, bounce=0.5 } ) local function onCollision( self, event ) local other = event.other if( event.phase == "began" and self.isBlock2 and other.isGround ) then timer.performWithDelay( 30, function() composer.gotoScene ( "restart", "fade", 0 ); end) self:removeEventListener( "collision" ) end return true end block2.collision = onCollision block2:addEventListener( "collision" ) end function scene:didEnter( event ) local sceneGroup = self.view end function scene:willExit( event ) local sceneGroup = self.view end function scene:didExit( event ) local sceneGroup = self.view display.remove( disposeGroup ) disposeGroup = nil end function scene:show( event ) sceneGroup = self.view local willDid = event.phase if( willDid == "will" ) then self:willEnter( event ) elseif( willDid == "did" ) then self:didEnter( event ) end end function scene:hide( event ) sceneGroup = self.view local willDid = event.phase if( willDid == "will" ) then self:willExit( event ) elseif( willDid == "did" ) then self:didExit( event ) end end scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) --------------------------------------------------------------------------------- return scene
What is the problem ? And note that nothing has transparent sides . Why does it appear to bounce on air ?
Thank you kind sir ^_^ .