Hello everyone - thanks for the help in my last post.. it got me in the right direction but now I'm stumped with a new problem.
I'm dropping a smaller ball into a bucket and upon doing so the ball is deleted and is replaced with a smaller ball at those coordinates. I'm using a table to track the creation of smaller balls.
I know my code is working fine up to the "print(#allballs)" line of code since I can see its adding to the index each time a small ball is dropped into the bucket. The code is also successfuly deleting the balls and replacing them with a new images of a smaller ball at the last coordinates of the larger ball. However, I'm stuck as to how I go about making the newly created smaller ball image a physical object.
I get a runtime error that at my physics.addbody line tell me that I'm attempting to call local 'ball' (a table value)
allballs[#allballs + 1] = display.newImage ("LargeBall.png")
local ball = allballs[#allballs]
ball.x = onesmallball.x
ball.y = onesmallball.y
ball.rotation = math.random (1, 360)
onesmallball:removeSelf()
print( #allballs )
physics.addBody( ball { density=0.4, friction=0.5, bounce=0.3 } )
Any ideas? My weak and fragile newbie hunch tells me that the device doesnt know which of the small balls to make physical... but then how does it know which of the small balls to turn into an image?
Thanks for your help!