Alright, I’m sure that the answer is a simple one I’m just missing, but here’s the problem:
I am drawing a rectangle to the screen through a function. Every time I call this function, I need the previous rectangle to be destroyed.
I had the code working fine by just moving one, but I don’t know how to resize physics bodies, so…
Anyways, here’s the code I have.
--handle reflector
--display.remove( object )
local reflector = display.newRect(0,0,math.abs(calculatehypotenuse(xoffset,yoffset)),15,2)
reflector:setFillColor(0,0,0,255)
physics.addBody(reflector, {bounce=1})
reflector.bodyType = "static"
I assumed that, because display.remove was before creating the shape, it would remove any existing reflectors. what it actually does is remove all the reflectors. Uncommenting it means that I draw reflector after reflector.
So how do I get rid of the earlier object? Is it stored in a table or something I can address? [import]uid: 48302 topic_id: 11799 reply_id: 311799[/import]
