문제

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