I'm currently making a game similar to this Nyan Cat flash game, although I'm using cocos2d. I'm having a hard time trying to make the rainbow effect:

enter image description here

Currently, every update call I add a piece of rainbow on screen and move it back, having also added it into a special array. When a player changes its y coordinate I rotate all the added spites by a certain calculated value.

Honestly, it looks... not perfect and I've been wondering if there is better way?

  • 2
    \$\begingroup\$ Think you can add an appropriate image instead of a link to a flash site? That would help this question stay useful. \$\endgroup\$ – MichaelHouse Jul 11 '13 at 13:29
  • \$\begingroup\$ Most likely the issue comes from you just rotating the sprites. I don't know if Cocos2d has something built in to help with rail rendering but if it does not you can make the curve piece by drawing the rainbow tile as a pie slice rather than an actual tile. I can't say I know the math behind this, but I'm guessing your issues come from drawing the tiles over one another. Without a image or a better explanation of what your issue looks like I can't really suggest anything more than that. \$\endgroup\$ – Benjamin Danger Johnson Jul 11 '13 at 16:29

There's a special class available in cocos2d that renders a ribbon of quads for you. At one point it was named CCRibbon, but I think it has been changed to CCMotionStreak (docs). It's designed to render trails or ribbons. I think using that class would be the most efficient way to create such an effect.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.