Hello,
Can anyone recommend a tutorial on how to work with multiple physics objects that are created from the same graphic. For example, I have a new copy of a bubble graphic appear every time a button is pressed. After a few presses you have a few bubbles launched onto the screen (1 per press). Okay… so I want to monitor the velocities of each bubble so that if it goes negative (i.e., the bubble starts falling down instead of floating up) then that bubble is erased. The code for creating the bubbles is shown below. Forgive my ignorance but how do I refer to a specific bubble when all have the same name of “bubble”? Thanks so much!
[code]
– ####### BUTTON PRESS HANDLER #######
local mainButtonHandler = function( event )
if event.phase == “press” then
local bubble = display.newImage(“images/bubble007.png”)
bubble.myName=“bubble”
localGroup:insert(bubble)
– Determine where to start the bubbles from
if nozzleAngle>90 then
bubble.x=nozzle.contentBounds.xMin
bubble.y=nozzle.contentBounds.yMin
else
bubble.x=nozzle.contentBounds.xMax
bubble.y=nozzle.contentBounds.yMin
end
– Make bubbles a physics body
physics.addBody( bubble, “dynamic”, {density = 1.5, friction = 0.3, bounce = 0, radius = 6})
[code]
[import]uid: 16901 topic_id: 7237 reply_id: 307237[/import]