Frage

Hi friends,
How to add sprites using init with file please let me know i am directly adding sprites in Resource folder and thus i am not getting any output. Output is blank screen how to handle it please help?

std::vector <CCSprite*> _sprites;
_sprites.reserve(10); 

for (int i=0;i < 5; i++)
 {
  CCSprite* foo = new cocos2d::CCSprite();
   foo->initWithFile( "sprites.png" );  // i am adding sprites but nothing being display??
     _sprites.push_back(foo);
      }
War es hilfreich?

Lösung

You need to add the Sprite to a Layer or something.

std::vector <CCSprite*> _sprites;
_sprites.reserve(10); 

for (int i=0;i < 5; i++)
{
   CCSprite* foo = cocos2d::CCSprite::create("sprites.png");

   _sprites.push_back(foo); // <- store your sprites to do stuff to them later.

   addChild(foo, 1); //<-- this is adding the child.
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top