Get updated location of object.x and object.y with Physics Engine
Hi I'm new to Corona SDK. I hope someone can help me out.
I have an object (called furry) dropping from the sky, using the physics
engine of the Corona SDK.
When this object Furry is half way the screen I would like to play a sound
effect (wee.mp3).
I'm trying to update furry.x and furry.y to control for the updated
location. But I'm not sure how to do this as the physics engine updates
the location based on gravity.
I hope the code below is sufficient to help me.
centerX = display.contentWidth * .5
centerY = display.contentHeight * .5
local furry = display.newImage("flurry.png")
furry.x = centerX-300
furry.y = centerY-1000
physics.addBody(furry, "dynamic", physicsData:get("flurry"))
if furry.x == centerX then
audio.play(wee)
end
So how can I get after the game has started the updated locations (x, y)
of my object Furry?
No comments:
Post a Comment