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);
      }
有帮助吗?

解决方案

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.
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top