accelerometer question

I’m trying to wrap my mind around the potential of the accelerometer. I have created a scene that contains a moving body object and a static body object. When the moving body collides the the static body, I want the moving body to remove itself and a new moving body to be added to the scene. Everything works except adding a new moving body. The most I can do is make a moving body visible or invisible. Am I asking too much from the accelerometer? Here’s a sample of what I’ve managed to get working.

[code]

local function onCollision (event)
if(event.other.name == ‘notch1’)then

shTileFin.isVisible = true;
shTile:removeSelf()
shTile=nil;
tile2.isVisible = true;
–I can’t get anything with physics to happen here
end

end [import]uid: 48122 topic_id: 8708 reply_id: 308708[/import]

Thats solves it! Thanks! [import]uid: 48122 topic_id: 8708 reply_id: 31849[/import]

You may not create or destroy objects during a collision. A workaround is to set a flag e.g. isToBeDestroyed=true for a display object and check that flag in enterFrame to determine when it’s necessary to destroy it. Hope it helps.

– Advanced UI + Graph for Corona® | Website | Forum (https) | See: [import]uid: 11385 topic_id: 8708 reply_id: 31746[/import]