Sunday, October 16, 2011

Cocos2d CCSprite Reflection

With yet another 2 months of Wild West Development behind me, I can hopefully get back to a somewhat normal life again, blogging, learning and a little iOS game development.

What I want to share today is my little hack to reflect a CCSprite used in to cocos2d. I say hack because it does feel a little dirty, i didn't go and learn about the details of Open GL and the like, simply patched things together to get a working solution.

Below is the code for my ImageReflector, the basic idea and how it got it work was simple:

The best looking reflection example I found was Apples' example. So the methods createBitmapContext, createGradientImage and reflectedImage are directly from the above example. I wanted to use it in cocos2d so I used CCRenderTexture to create a UIImage, passed that to Apples' example code and then simply converted back to a CCSprite with the help of the CCTexture2D class.

Usage: Class:

4 comments:

  1. It's cool that you report such things.

    ReplyDelete
  2. very informative and knowledgeable

    ReplyDelete
  3. Players who have sufficient eso gold can buy potions, motifs, houses, and a number of other products within the game. A safe and secure site called MMOGAH can make it easier for players to buy eso gold immediately. Far better is to official site or check out our own established site to find out related to eso gold.

    ReplyDelete

Popular Posts

Followers