FIRST CASE : If i create an object outside of a function and applyForce to it i can track the object.x and object.y
local ball = display.newImage( "ball.png")
ball.x = 10
ball.y = 10
ball:setReferencePoint(display.CenterReferencePoint);
physics.addBody( ball, { density=0.02, friction=0.1, bounce=0.5,radius=20 } )
ball:applyLinearImpulse ( 0.1, -0.2, ball.x, ball.y)
function start()
print(ball.x)
print(ball.y)
end
Runtime:addEventListener("enterFrame", start)
SECOND CASE: If I create an object instances inside of a function calling it with a timer how can i track the object.x and object.y??
function createball()
ball = display.newImage( "ball.png")
ball.x = 10
ball.y = 10
ball:setReferencePoint(display.CenterReferencePoint);
physics.addBody( ball, { density=0.02, friction=0.1, bounce=0.5,radius=20 } )
ball:applyLinearImpulse ( 0.1, -0.2, ball.x, ball.y)
function start()
print(ball.x)
print(ball.y)
end
timer.performWithDelay (1000,createball,100)
Runtime:addEventListener("enterFrame", start)
Any help? [import]uid: 74718 topic_id: 12703 reply_id: 312703[/import]