IPhone and Cocos2d Sprites/Layers

I am using cocos2d-iphone to place Sprites onto a Layer to setup a game playfield. At certain points in the game, certain Sprites need to be removed based upon game conditions. What I would like to do is setup an array of Sprite pointers, but I have two questions:

What's the best way to place Sprite pointers in an array?

How does one remove the Sprite in cocos2d with only a pointer to the Sprite? I know how to do it from its parent layer, but that is too runtime intensive for the main game loop.

Thanks in advance!

Answers


The Sprite class inherits from CocosNode, so you should be able to call spritePointer.parent.remove(spritePointer)


Need Your Help

openssl command doesn't work so can I use php openssl functions instead

php openssl

I think I asked this twice already and no one even bothered to view this. please help me out and try to at least think about it before forgetting the question.

Queue alternatives to MSMQ on Windows?

.net msmq soa messaging

If you want to use a queuing product for durable messaging under Windows, running .NET 2.0 and above, which alternatives to MSMQ exist today? I know of ActiveMQ (http://activemq.apache.org/), and I...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.