Is it possible to add a child to a sprite and when I set the parent INvisible, the child stays visible? I thought turning off honor parent transform would work but it's not. And if I set child visible after setting parent INvisible, it's ignored.
Keep child visible when parent invisible
(5 posts) (3 voices)-
Posted 1 year ago #
-
Try calling [child visit] in a visible objects draw function.
Posted 1 year ago # -
What if you just set the opacity to 0 instead of visible:NO?
Posted 1 year ago # -
I'm using spritesheets so I cannot call visit.
This works with visible:NO or opacity:0. But I need the child to continue to follow the position of the invisible parent, which now it does not. It does not move even though the parent is moving. It think because position is grouped in with visibility as transformations.
[mask setHonorParentTransform: 0];Since my parent is a subclass of CCSprite, I tried overriding setVisible to not touch children but that seem to get ignored.
Posted 1 year ago # -
Is the sprite sheet added to your main layer or your subclass of CCSprite?
If it is on your main layer, you need to over ride the -setPosition function (of your parent CCSprite) with this.
-(void)setPosition:(CGPoint)p { float x = position_.x-p.x; float y = position_.y-p.y; child.position = ccp(child.position-x,child.position.y-y); position_ = p; isTransformDirty_ = isInverseDirty_ = YES; }Posted 1 year ago #
Reply
You must log in to post.