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로 변경하면 완벽하게 작동하지만 contetSize가 설정된 CCNode를 사용하지 않는 이유는 무엇입니까? CCNode를 사용하려면 어떻게해야합니까?
당신은 CCNode에 대한ccp(0.5,0.5)
가되도록
anchorPoint
을 설정해야합니다 당신에게 소렌
대단히 고마워요. 나는 이걸로 고생했습니다! – Neigaard