我有一个CCSprite
从 cocos2d 框架延伸的背景。我已经将这个精灵添加到了游戏层。现在在这个背景类中,我尝试CCSprites
像这样添加其他命名的 Star:
//create the stars
stars = [[CCArray alloc] init];
for (int i = 0; i < 10; i++)
{
Star* star = [[Star alloc ] initWithFile:@"star-hd.png"];
CGSize screensize = [[CCDirector sharedDirector] winSize];
//CCLOG(@"screensize: %f, %f", screensize.width, screensize.height);
CGPoint newstarlocation;
newstarlocation.x = CCRANDOM_0_1() * screensize.width;
newstarlocation.y = CCRANDOM_0_1() * screensize.height;
star.position = newstarlocation;
[self addChild:star z:i];
[stars addObject:star];
}
但星星不会出现。我尝试了几件事,唯一似乎有效的是当我在游戏层而不是背景上添加星星时。但这不是我想要的。
cocos2d中不允许嵌套精灵吗?如果允许,我如何嵌套精灵?