嗨朋友们,
如何使用init与文件添加精灵请让我知道我直接在资源文件夹中添加精灵,因此我没有得到任何输出。输出是空白屏幕如何处理请帮忙?
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);
}
答案 0 :(得分:0)
您需要将Sprite添加到图层或其他内容。
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.
}