Hey guys I am building a physics puzzler type game and I am running into the same error no matter what I change. The physics does not work properly when the “ball” falls it falls like its hitting stuff that is not their and sometimes does not fall at all. Any Ideas
Thanks Tyler Jacobson P.S I have attached a video link showing what happens
below is code from the level 2 file.
--level2.lua local sceneName = ... local composer = require( "composer" ) -- Load scene with same root filename as this file local scene = composer.newScene( sceneName ) --------------------------------------------------------------------------------- function scene:create( event ) local sceneGroup = self.view local physics = require("physics") local bg = display.newRect(200,250,700,700) physics.start() local rect = display.newRect(50,80,130,20) rect:setFillColor(255,150,0) physics.addBody(rect,"static") local ball = display.newCircle(50,30,30) ball:setFillColor(0,255,0) physics.addBody(ball,"dynamic") local rect2 = display.newRect(50,300,130,20) rect2:setFillColor(255,0,0) rect2:rotate(20) physics.addBody(rect2,"static") local rect3 = display.newRect(250,330,130,20) rect3:setFillColor(255,0,0) rect3:rotate(-50) physics.addBody(rect3,"static") local rect4 = display.newRect(50,430,130,20) rect4:setFillColor(255,0,0) rect4:rotate(20) physics.addBody(rect4,"static") local function destroyplatform( self,event ) rect:removeSelf() end rect:addEventListener("touch",destroyplatform) local rect5 = display.newRect(190,450,130,20) rect5:setFillColor(255,150,0) physics.addBody(rect5,"static") local rect6 = display.newRect(190,480,130,20) rect6:setFillColor(0,0,255) physics.addBody(rect6,"static") local rect7 = display.newRect(200,520,400,20) physics.addBody(rect7,"static") local function destroyrect5( self,event ) rect5:removeSelf() end local function lose( event ) composer.removeScene("level2") composer.gotoScene("lose") end local function changescene( event ) composer.gotoScene("win") end rect7:addEventListener("collision",lose) rect5:addEventListener("touch",destroyrect5) rect6:addEventListener("collision",changescene) sceneGroup:insert(bg) sceneGroup:insert(rect) sceneGroup:insert(rect2) sceneGroup:insert(rect3) sceneGroup:insert(rect5) sceneGroup:insert(rect4) sceneGroup:insert(rect6) sceneGroup:insert(ball) sceneGroup:insert(rect7) end function scene:show( event ) local sceneGroup = self.view local phase = event.phase if phase == "will" then -- Called when the scene is still off screen and is about to move on screen elseif phase == "did" then -- Called when the scene is now on screen -- -- INSERT code here to make the scene come alive end end function scene:hide( event ) local sceneGroup = self.view local phase = event.phase if event.phase == "will" then -- Called when the scene is on screen and is about to move off screen -- -- INSERT code here to pause the scene -- e.g. stop timers, stop animation, unload sounds, etc.) elseif phase == "did" then -- Called when the scene is now off screen end end function scene:destroy( event ) local sceneGroup = self.view -- Called prior to the removal of scene's "view" (sceneGroup) -- -- INSERT code here to cleanup the scene -- e.g. remove display objects, remove touch listeners, save state, etc end --------------------------------------------------------------------------------- -- Listener setup scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) --------------------------------------------------------------------------------- return scene