Showing only a parent size content of all child sprites

Showing only a parent size content of all child sprites
0.0 0


Assume I have 2 Sprites with size of 500x500. assume I create one of the sprites a parent of the other and place the other sprite in the position of 250,250, I will see the two sprites while the second sprite is over the size of its parent.

What I want to accomplish is to avoid that. I want that a parent node will clip the child sprites. so in my example, I should see only 250x250 of its original size.

Is there a way to accomplish that ?


Hi ,
you can use Mask , these are useful links , check’em out :


Thanks . That is working. But the real reason I need it is to somehow control the size of the clipping node in real time. I am trying to implement a progress bar with animated solid fill and I wish to make the bar size changed. SetContentSize does not work on a sprite with an action so I tried using stencil.

Stencil does work but I can not change in real time.


hmmm , sorry man i don’t know how you can do that. i will try to make it happen and if could do it , i will inform you :wink:


You can change the stencil node in real time.

If the progress bar is rectangular, try using a LayerColour instead of DrawNode. That way you can simply use setContentSize to change it’s size as needed (including in an Action). Otherwise, you’d have to keep clearing and redrawing the DrawNode.


Your suggestion was very helpful I did manage to solve it with a Stencil.


@xikka Thanks. I used a different approche finally. I used setPosition on the stencil node to make that effect. Working well :slight_smile: