@ BWernsman
You have a few different ways to do this you could set a collision function like rahulsingh2k10 explained the only problem with his code and I dont think you want that is every there is a collision the ball will jump and im going to assume you want to make it jump by touching the screen or button or ball ect? This sample should give you the right idea there are other ways to doing this you could keep a Runtime checking for a collision event or a timer for when ball jumps in X seconds you can jump again or instead of the ball having a collision function the floor can so every time ball hits floor you jump again ect… it all depends on you but this should get you started. Im a bit late on reply been busy hope this helps
Best of Luck,
LeivaGames
[lua]local physics = require (“physics”)
physics.start()
physics.setGravity(0, 10)
local jump_completed = false
local circle = display.newCircle(0, 0, 20)
circle.x = 240
circle.y = 290
physics.addBody(circle, “dynamic”, {bounce=0.1})
local floor = display.newRect(0, 0, 480, 1)
floor.x = _W
floor.y = 320
physics.addBody(floor, “static”, {bounce = 0, friction = 0.1} )
floor.isVisible = true
local function circle_jump(event)
if(event.phase == “ended” and jump_completed == false)then
jump_completed = true
circle:setLinearVelocity(0, -250)
end
end
Runtime:addEventListener(“touch”, circle_jump)
local function on_hit(event)
if(event.phase == “began”)then
jump_completed = false
end
end
circle:addEventListener(“collision”, on_hit) [import]uid: 30314 topic_id: 19601 reply_id: 76378[/import]