Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

How to remove a Cocos2D sprite from a layer?

JohanovskiJohanovski Posts: 343Registered Users @ @
edited May 2010 in iPhone SDK Development
Hi there!

I'm working in a Cocos2D scene where I have a pack of sprites added as children in a GameScene that inherits from CCLayer. When I want to change the whole scene I know that I can remove all children with this line (if I'm not wrong, which also can be):
[self removeAllChildrenWithCleanup:YES];

However how can I remove a single sprite at a certain point of the game? I've tried the following but it doesn't work:
// myObject is a custom class that contains a pointer to it's sprite
[self removeChild:myObject.sprite cleanup:YES];

I think it should be something like what I've done, but what?

Thanks in advance for your time! :)
Post edited by Johanovski on

Replies

Sign In or Register to comment.