HI guys, i am creating one small jump game. Players will have to use accelerometer to move player left or right and help the character to land on the rocks in middle of pond. For score collect coins from midair… simple
For this i have following code… unfortunately i am not able to achieve smooth movements, and i really dont know the logic which i used for jump is correct or not.
[code]
physics.setGravity(0,8)
–CODE FOR MOVING PLAYER
function movePlayer(e)
–(Using this code from brick breaker game tutorial from tuteplus)
frog.x = display.contentCenterX - (display.contentCenterX * (e.yGravity*2))
end
Runtime:addEventListener(“accelerometer”, movePlayer)
–Player Jump logic
(Player will be thrown up in the air again as soon as it touch the base)
local function onCollision(event)
local object1 = event.object1.name
local object2 = event.object2.name
if event.phase == “began” then
if object1 == “base” and object2 == “frog” then
frog:setLinearVelocity(0, -300)
end
end
end
[code]
I want my character to jump this high but little faster. How can i control this… any help will be appreciated.
Thanks in advance. [import]uid: 83799 topic_id: 26807 reply_id: 326807[/import]
