There should be an object/method that will apply force on the other objects as if a bomb exploded.
I should be able to specify the x,y, velocity, and possibly the decay. [import]uid: 21962 topic_id: 5654 reply_id: 305654[/import]
There should be an object/method that will apply force on the other objects as if a bomb exploded.
I should be able to specify the x,y, velocity, and possibly the decay. [import]uid: 21962 topic_id: 5654 reply_id: 305654[/import]
box2d example, maybe something like this can be worked in to corona sdk
[java]
/**
*
* @param locationPnt Application point of the explosion
* @param nRadius Radius of the explosion in pixels
* @param nForce Force of explosion
*/
private function physExplosion(locationPnt:Point, nRadius:Number, nForce:Number) : void {
var aabb:b2AABB = new b2AABB();
aabb.lowerBound.Set((locationPnt.x - nRadius) / METER, (locationPnt.y - nRadius) / METER);
aabb.upperBound.Set((locationPnt.x + nRadius) / METER,(locationPnt.y + nRadius) / METER);
var k_bufferSize:Number = BODY_NUM;
var buffer:Array = new Array();
var count:int = _pSim.w.Query(aabb, buffer, k_bufferSize);
for (var i:Number = 0; i< count; ++i) {
var pBody:b2Body = buffer[i].GetBody();
var pBodyPos:b2Vec2 = pBody.GetWorldCenter();
var pHitVector:b2Vec2 = new b2Vec2(pBodyPos.x - locationPnt.x/METER, pBodyPos.y - locationPnt.y/METER);
var radDist:Number = pHitVector.Normalize();
radDist = (radDist * METER);
if (!pBody.IsStatic() == (radDist<=nRadius)){
pBody.WakeUp();
var nHitForce:Number = ((nRadius-radDist) / nRadius) * nForce;
var appForce:b2Vec2 = new b2Vec2(pHitVector.x*nHitForce,pHitVector.y*nHitForce);
pBody.ApplyImpulse(appForce, pBody.GetWorldCenter());
}
}
}[/java] [import]uid: 21962 topic_id: 5654 reply_id: 19341[/import]