I'm currently working in an Angry Bird-esque game, where the user flings a bomb at buildings and the bomb explodes.

How do I create explosions in Corona? Essentially some sort of area of effect explosion should occur on collision, which pushes all the elements within the area out of the way (this could probably be done with applyForce)

I've tried the following, but left me with lackluster results:

function setExplosion(self, event)
    event.other:applyForce(300, 300, circle.x + (circle.width/2), circle.y + (circle.height/2))

Note that the circle is the explosion radius.

Anybody have any tips on creating explosions?


function setExplosion(self, event)
    event.other:applyForce(500, 500, circle.x + (circle.width/2), circle.y + (circle.height/2))

function drawExplosion(eventX, eventY)
    return function()
        circle = display.newCircle( eventX +20, eventY +20, 150 )  
            circle.myName = "circle"  
       circle:setFillColor(100,100,100, 100)  
     physics.addBody( circle, "static", {isSensor = true} )  
        circle.collision = setExplosion  
        circle:addEventListener( "collision", circle ) 
  • \$\begingroup\$ Could you please provide some description (or better yet, a YouTube clip or something) describing what is happening that is undesirable? My assumption is that you are not setting the explosion force reference to the proper location, or not scaling down the force the further out you go, but I don't know what is happening that you don't like. \$\endgroup\$ Commented Mar 29, 2013 at 16:20
  • \$\begingroup\$ On second thought, are you sure you're using the proper arguments to applyForce? According to docs.coronalabs.com/api/type/Body/applyForce.html, the first two arguments should be xForce and yForce, which you are setting to 300, 300. This means the body will experience a force pointing +300 X and +300 Y, or in the same direction every time. \$\endgroup\$ Commented Mar 29, 2013 at 16:23
  • \$\begingroup\$ I voted to close this because you're asking for "tips" on "creating explosions" which is broad and discussion oriented. You'd get better quality answers, probably, if you focused more on describing the specifics of the result you want, why your current efforts are not good enough, and asking how you can bridge that gap. \$\endgroup\$
    – user1430
    Commented May 10, 2013 at 19:13

1 Answer 1


From my limited knowledge and research, you seem to be incorrect in application of the force from the explosion. My above comments discuss this further, but put simply, you should not be applying a uniform force of {300, 300} to all bodies, unless you want to hurl them at a 45-degree angle with the same amount of force. If you want a realistic explosion, you should be applying a somewhat normalized force outwards from the center of your explosion to each body, and scale it down based on distance from the explosion's center.

The general procedure I follow for processing explosions is this:

  • Locate the area of influence, and enumerate all bodies within it. (This is the part you seem to have down already.)
  • For each body, calculate two points:

    • The "target point", which is a point (or multiple points; you can get creative here) on the body at which the force is applied.
    • The center of the explosion (which you have already done).
  • Get the direction of the explosion's force upon the body, by subtracting the center point from the target point.
  • Normalize the vector to get the core directional vector.
  • Based on the original (non-normalized) vector's magnitude, apply some distance scaling function to the normalized vector to get your resultant force vector.

    • One possible way would be to multiply the normalized vector by some large "explosion power" value, then divide it by the squared magnitude of the original vector to scale it down.
  • Use the resultant force vector's X and Y components as the first two arguments to applyForce, and the target point's X and Y components as the last two.
  • \$\begingroup\$ I had an inkling that this might be the case. I'm not quite sure how I'm supposed to determine where the objects are, related from each other. I've added some more information to the first post, showing what I have so far. \$\endgroup\$
    – Cleverbird
    Commented Apr 2, 2013 at 7:15

Not the answer you're looking for? Browse other questions tagged .