Rays of light from behind an object

I’ve seen this visual effect in a number of games: a set of rays emanating from a single point, often rotating slowly, with each ray distinctly separable from others, e.g.:

I guess it is a standard particle system or an example in Unity, but I was wondering what would be the easiest way to create it in cocos2d-x? I need to be able to control the exact number of rays emanating.

Thank you!

Hi,
this is done by using a static png image with fixed number of rays in a radial array, just as what you see in that screen capture.
And then, you can use CCAction to give it a rotation animation.

Thank you Darren!
Haven’t thought about using PNG with transparencies for this, but it does make a lot of sense. My problem is that I need the number of rays to be programmatically generated depending on a value they would reflect. Any idea what would be the best way of doing it programmatically? I’ll have to change the angle of each depending on how many of those I have. For example, if my value is 1, regular light from behind the object is fine. If the number is 2, i need 2 sectors, probably flexible on how wide they are, and so forth.

Hmm i haven’t implemented something like that before just for a decorative effect.
But probably you can use a single ray image and then create the count of sprites you need? and programmatically arrange them in a radial fashion.
As for the dynamic width, you can try tweaking the scale… not sure if it will look great though…