I am trying to get my character to “jump” as viewed from the top down, which consists of :
- move upward i.e. decrease y position
- scale up and then back down i.e. look bigger as you jump up and then get smaller as you land
This is combined with camera tracking implemented in the enterFrame function.
I do this with two transitions, one to “jump up” and then another in its onComplete to “jump down”.
It appears that the animation stutters between the jump up and down and it has something to do with the camera tracking implementation.
NOTE: If the jump distance is decreased to 100px, for example, the animation looks fine.
Also, if you take out the x/y scaling it still stutters.
Any ideas?
[code]
display.setStatusBar( display.HiddenStatusBar )
local stageGroup = display.newGroup()
local physics = require (“physics”)
local player
local jumpPlayer = function()
local jumpTime = 1200
local jumpDist = 1000
local downJump = function()
transition.to(player, {time=jumpTime/2, y=player.y-jumpDist, xScale=1, yScale=1, x=player.x})
end
transition.to(player, {time=jumpTime/2, y=player.y-jumpDist, xScale=2, yScale=2, x=player.x, onComplete=downJump})
end
local function onTouch (event)
if event.phase == “began” then
jumpPlayer()
end
end
local function enterFrame(event)
– moves camera when player moves upward
local topBound = 200
if player.y < topBound then
stageGroup.y = (player.y * -1) + topBound
end
end
local function initGame()
physics.start( true )
physics.setScale( 100 )
physics.setGravity(0, 0)
player = display.newCircle(0, 0, 10)
player.x = display.contentCenterX
player.y = display.contentCenterY + 100
physics.addBody( player , “dynamic” ,{ bounce = 0 , friction = .01, density = 10 , radius = 8 } )
stageGroup:insert(player)
end
initGame()
Runtime:addEventListener( “touch”, onTouch )
Runtime:addEventListener( “enterFrame” , enterFrame )
[/code] [import]uid: 63043 topic_id: 26785 reply_id: 326785[/import]