Hey guys im currently working on a rapid prototype for a general idea and am having issues with physics engine. Whats happening is the ball will go halfway through the second platform but never all the way through?
Heres the code and keep in mind its not optimized or anything as its just prototyping.
-- Include all the required external files local perspective = require("perspective") local physics = require("physics") -- Hide status bar display.setStatusBar(display.HiddenStatusBar) -- Setup camera local camera = perspective.createView() --Start Physics physics.start() physics.setGravity(0, 1) physics.setDrawMode("hybrid") -- Useful Variables \_H = display.contentHeight -- Make Display Objects local background = display.newImageRect("bg.jpg", 2000, 2000) local ball = display.newCircle(0, 0, 20) local floor1 = display.newRect(0, 0, 500, 40) local floor2 = display.newRect(0, 0, 1000, 10) -- Position Display Objects ball:setReferencePoint(display.CenterReferencePoint) ball.x, ball.y = 20, 20 floor1:setReferencePoint(display.CenterLeftReferencePoint) floor1.x, floor1.y = 0, 65 floor2:setReferencePoint(display.CenterLeftReferencePoint) floor2.x, floor2.y = 230, 200 floor2.rotation = -5 -- Add physics to all objects physics.addBody(ball, "dynamic", {radius = 20}) ball.isBullet = true physics.addBody(floor1, "static", {}) physics.addBody(floor2, "static", {}) -- Add Display Objects to camera camera:add(background, l, false) camera:add(ball, l, true) camera:add(floor1, l, false) camera:add(floor2, l, false) -- Start Camera Tracking camera:track() camera:setBounds(false) -- Add temp buttons for control local rButton = display.newRect(0,0,50,10) local lButton = display.newRect(0,0,50,10) -- Position buttons rButton:setReferencePoint(display.CenterReferencePoint) rButton.x, rButton.y = 130, \_H - 30 lButton:setReferencePoint(display.CenterReferencePoint) lButton.x, lButton.y = 40, \_H - 30 local function MoveBallR(event) -- Move the ball if event.phase == "began" then print("Move Right") ball:applyForce(1, 0, ball.x, ball.y) end end local function MoveBallL(event) -- Move the ball if event.phase == "began" then print("Move Left") ball:applyForce(-1, 0, ball.x, ball.y) end end rButton:addEventListener("touch", MoveBallR) lButton:addEventListener("touch", MoveBallL)
I am using the Perspective file found here
I have tryed isBullet, physics.setScale, iterrations, thickening the walls, and several other things that I have found all make zero difference in the actions.
Thanks for all the help in advanced!