GoldenJoe
GoldenJoe

Reputation: 8002

How to mask sprites in cocos2d?

I've read Ray Wenderlich's tutorial on sprite masking: http://www.raywenderlich.com/4428/how-to-mask-a-sprite-with-cocos2d-2-0. However, my understanding of openGL is poor, and this tutorial doesn't produce the effect I desire. What I would like to do is to mask one sprite/layer with another, and move the sprite behind the mask to create a "shiny" animation, like so:

enter image description here

Additionally, how could I make the mask dynamic (ex: changing the text string), and how could I make a sprite or layer count its children as part of the mask?

Upvotes: 2

Views: 3131

Answers (2)

wolverineun
wolverineun

Reputation: 21

I think you con do that with an animation, put the "reflection sprite" under the "mask sprite" and then move the "reflection sprite" from left to right.

Upvotes: 1

tom
tom

Reputation: 1

I think this Github repository will help you.

https://github.com/tonybeltramelli/Cocos2D-Mask-Shader

Upvotes: 0

Related Questions