0
我在我的初始化這個代碼:CCSprite是錯誤
-(id)init {
if ((self = [super init])) {
CGSize screenSize = [CCDirector sharedDirector].winSize;
mapSize = CGSizeMake(4000, 4000);
rotateWorld = [CCNode node];
[rotateWorld setContentSize:mapSize];
rotateWorld.position = CGPointMake(screenSize.width/2, screenSize.height/2);
positionWorld = [CCNode node];
[positionWorld setContentSize:mapSize];
positionWorld.position = CGPointMake(mapSize.width/2, mapSize.height/2);
[rotateWorld addChild:positionWorld z:0];
[self addChild:rotateWorld z:0];
// Test enemy
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"EnemiesSpritesheet.plist"];
spriteSheetNonPlayer = [[CCSpriteBatchNode alloc] initWithFile:@"EnemiesSpritesheet.png"capacity:10];
[positionWorld addChild:spriteSheetNonPlayer z:0];
enemy = [[Enemy_01 alloc] initWithSpriteFrame:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:@"enemy_01_01.png"]];
enemy.position = CGPointMake(mapSize.width/2, mapSize.height/2);
[spriteSheetNonPlayer addChild:enemy];
}
return self;
}
現在,我希望我的敵人精靈在屏幕中間顯示出來,但它不我不知道它是否顯示。有趣的是,如果我將positionWorld從CCNode更改爲包含4000x4000背景圖像的CCSprite,它可以很好地工作,但爲什麼不用CCNode設置contetSize?我如何得到這個與CCNode一起工作?
謝謝 瑟倫
非常感謝你,我一直在爲此付出努力! – Neigaard