Helix
Helix

Reputation: 125

Get sprite image from ccarray in cocos2dx

I need to get sprites from ccarray. am using cocos2dx 2.2.2

For example, i stored around 5 sprites in ccarray when collision detection happens. if(array count >= 1) those sprite image will be available to use as power. there i need to get first image form array after usage i need to remove form array. so again it will display top most image as power. like this it will go on.

Code for storing in array (Collsion detction)

           CCSprite * powersprte = CCSprite::create("Images/Objects/conepower.png");
           PowerArray->addObject(powersprte);

now, how to retrive top most image from power array.

Upvotes: 0

Views: 397

Answers (1)

Helix
Helix

Reputation: 125

using this CCSprite * sprte = dynamic_cast<CCSprite*>(PowerArray->objectAtIndex(0));

easily get sprite image from array

Upvotes: 1

Related Questions