I’m in pre development for a game that will hopefully have a sonar type effect. I.e. You cant see anything, then you send out a sonar ping and as the ping hits objects they becom illuminated. Does anyone have any ideas of where I would start. I’m using cocos2d so it’s a sidescroller type game. Any help would really really help.
Share
Keeping it simple, here is what I would do. Every update after the sonar is sent out, use
ccpDistanceand check if the distance between the start of the sonar and all of the objects you want to check is less than some variableithat gets incremented every update. In effect this is basically a growing circle that checks for objects inside its radius.If the distance is less than
i, run an action on the sprite, such as[self runAction:[CCFadeOut actionWithDuration:5]]. This will show the object then fade it out over a duration of 5. If you set the object to visible = false beforehand, you should get a nice sonar effect.If you need the direction just get the vector from the sonar start position to the object when it is visible.