Cocos2DXNA/cocos2d-xna — pull request #405 by totallyeviljake (2014-03-23 18:38:02+00:00)
Title: Issue 403 - Lightning effect

This implementation is a single bolt as a CCDrawNode. You can create a series of strikes by adding more bolt instances. See the DrawPrimitivesTest for details:

public override void TouchEnded(CCTouch touch)
{
base.TouchEnded(touch);
CCLightning node = (CCLightning)GetChildByTag(55);
node.AddBolt(new CCLightningBolt()
{
BoltColor = CCLightning.LightningBlue,
BoltGlowColor = CCLightning.LightningBlue,
Start = CCDirector.SharedDirector.WinSize.Center,
End = ConvertToNodeSpace(touch.Location),
StrikeTime = (2f * CCMacros.CCRandomBetween0And1()),
FadeTime = 0.15f,
Width = .5f
});
}
StrikeTime is the amount of time, in seconds, that it takes for the lightning to strike its target. The FadeTime is the amount of time for the strike to fade out.

This PR also include some optimizations to the CCDrawNode to cache a filtered array of primitives so that the hard 65535 primitive limit in XNA doesn't get triggered in CCDrawManager.