Hey guys this is an entirely new concept for me and I need some help. How would I make a bomb in a game that will delete objects within a set radius? I know how to have an image of a bomb appear on the screen but not necessarily how to have the objects within it’s radius affected by an explosion. Thanks for any help. [import]uid: 35535 topic_id: 10603 reply_id: 310603[/import]
I keep an array of my on screen objects and use a function like this:
local function checkCollateralDamage(x, y, targetSize, size)
local i
for i = 1, totalTargets do
if targets[i] ~= nil then
local sqrt = math.sqrt
local dx = x - (targets[i].x);
local dy = y - (targets[i].y);
local distance = sqrt(dx\*dx + dy\*dy);
local objectSize = (targetSize/2) + (size / 2)
if (distance \< objectSize) and (math.random(2) == 1) then
killTarget(i)
end
end
end
end
size is the size of the explosion and targetSize is the size of the object (object.displayWidth) I’m checking
Now I only want a 50/50 chance that the explosion will take out an object, ergo the math.random(2) check. [import]uid: 19626 topic_id: 10603 reply_id: 38551[/import]
There are also a couple of nice examples here
http://mobile.tutsplus.com/tutorials/corona/corona-sdk_physics_explosions/ [import]uid: 11672 topic_id: 10603 reply_id: 38552[/import]