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.

1
2
3
4
5
6
7
8
9
10
11
12
13
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

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:

Thats solves it! Thanks!

views:1727 update:2011/10/4 8:06:35
corona forums © 2003-2011