physics = require “physics”
physics.start()
physics.setGravity( 0, 8)
local boxGround = display.newRect(0, 450, 340, 50)
boxGround:setFillColor(140,140,140)
physics.addBody(boxGround, “static”, {density = 1.0, friction = 0.3, bounce = 0.2, isSensor = false})
local boxCharacter = display.newRect( 320/2, 400, 50, 50 )
physics.addBody(boxCharacter, “dynamic”, {density = 1.0, friction = 0.3, bounce = 0.2, isSensor = false})
local function boxJump (event)
if event.phase == “began” then
transition.to(boxCharacter, {time = 700, y = boxCharacter.y - 250 } )
end
end
Runtime:addEventListener(“touch”, boxJump)
I am using this code to make a box jump on the screen, but the jump is ugly like it is hitting a invisible wall. Can anyone help? Thanks
[import]uid: 39533 topic_id: 27055 reply_id: 327055[/import]