Collision detection question

Hi,

Information
Im coding up a simplistic/“similair to” version of Missile Commmand. Basically a space station sitting in orbit and asteroids are hurtling towards it and need to be shot down with missiles. Similair to missile command… when the missile reaches its destination (touch event) the missile explodes and creates and expanding circular explosion. At the moment I am using a basic circle that sclaes in size over a second or 2 which I will be replacing the circle with an image.

Question
With the current limiation of physics bodies not being able to be scaled, how will I do collision detection with my circle/images? I thought I seen some code for it but may be wrong. Tried a few searches but had no luck… looked through the API too =\ [import]uid: 83851 topic_id: 14336 reply_id: 314336[/import]

Ya, that sukz, i know…

You will find a couple examples of expanding circle collision in here, i read them as well. In the end had to track point within circle manually. I really hope they add something for this…need to find time to add this to the wish list here…now where was that… lol…

I’ll slide you a few lines of code, but don’t have time for fully tested (for your particular case) example right now…

the tmpRadius is always expanding coming in from weaponA.aoeBullet.xScale (the transition that is taking place)
and this activity is taking place within the main game loop (if weaponA.aoeBullet.isActive kind of thing)

local tmpRadius = (weaponA.aoeBullet.width *.5) * weaponA.aoeBullet.xScale
local isCollision = isInCircle(weaponA.aoeBullet.x, weaponA.aoeBullet.y, tmpRadius, playerGroup[2].x, playerGroup[2].y)

local Pow = math.pow
function isInCircle(cX, cY, r, x, y)
local dist = Pow(cX - x, 2) + Pow(cY - y, 2)
return dist <= r*r
end

hope this gets you in the right direction. [import]uid: 21331 topic_id: 14336 reply_id: 52960[/import]

You lost me a little with your code but I get the idea of what you are talking about.

You are tracking all (x,y) coordinates within the blast zone and if any objects hit any of those coordinates, then thats a collision detected? Might not be totally accurate for the edge detection but should be enough.

So it’s as you said, our own collision code instead of getting the backend to do it for us.

[import]uid: 83851 topic_id: 14336 reply_id: 52963[/import]

Right. Box2D limitation i guess (changing object shape during simulation)

This is from my code and is pretty darn accurate at 30 FPS. (i may be using 60, now can’t remember).

I wish I could have bumped into this code when i was looking for it that’s for sure!! Trust me, this is one solution that does work. Just check if an AOE is active during your main EnterFrame loop. I did not create an event based version though…have to think about that one a bit longer…:wink: [import]uid: 21331 topic_id: 14336 reply_id: 52966[/import]