A function that creates an explosion:
local Explosion = function( x, y, size )
local explosion = sprite.newSprite( fxExplosionSpriteSet )
explosion.x = x
explosion.y = y
explosion.explosion = true
if size then
explosion:scale( size, size )
else
explosion:scale( 1.5, 1.5 )
end
explosion:prepare( "fx\_explosion" )
explosion:play()
explosion:addEventListener( "sprite", KillSprite )
--physics.addBody( explosion, "dynamic", { isSensor = true, density = 5.0, friction = 0.5, bounce = 0.3 } )
end
Occasionally there are items on the screen and if the player taps on one it is handled as follows:
if item.itemType == ITEM\_HEALTH then
SetHealth( health + 10 )
elseif item.itemType == ITEM\_ENERGY\_X2 then
elseif item.itemType == ITEM\_ExP\_X2 then
elseif item.itemType == ITEM\_BOMB then
Explosion( item.x, item.y, 3 )
end
The bomb item leaves an explosion that kills any enemy it touches while it exists. I was trying to add a physics body to the explosion to detect collision events but when I do I get the following crash:
Assertion failed: (IsLocked() == false), function CreateBody, file /Users/ansca/.hudson/jobs/Pong-DMG/workspace/platform/mac/…/…/external/Box2D_v2.1.2/Box2D/Box2D/Dynamics/b2World.cpp, line 84.
/Applications/Corona Game Edition Alpha 2/Corona Terminal: line 9: 43606 Abort trap “$path/Corona Simulator.app/Contents/MacOS/Corona Simulator” $*
logout
[import]uid: 6259 topic_id: 1637 reply_id: 301637[/import]
Did you ever find a workaround for this? [import]uid: 7177 topic_id: 1637 reply_id: 5055[/import]
[import]uid: 11130 topic_id: 1637 reply_id: 11966[/import]
[import]uid: 34945 topic_id: 1637 reply_id: 47083[/import]