Categories
Featured iPhone Development Resources iOS Development Source Code Examples

Example: Create A Lightning Effect In Cocos2D Using OpenGL ES

Lightning is one of those effects that is greatly sought after in 2D games, you can use it to set up a spooky scene, have a bolt of lightning shoot a player character, blow up a section of bricks or pretty much anything you can come up with.

I’ve come across a class that allows you to easily add a dynamic lightning effect to your Cocos2D games.  This is done by directly drawing on the OpenGL ES scene so you could take this code, and easily modify it to work in any app that draws to the screen using OpenGL ES.

Here’s a demo of the class in action:

This version of the lightning class is from SupersuRacoon and can be downloaded through this post here: Simple Lightning Effect Demo.  This version of the class allows you to set all strike points for the lightning effect.

This was originally discussed on the Cocos2D forums here and you can find the original class from Mobile Bros on their website here.

A very nice lightning effect.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.