0
게임 플레이가있는 장면과 허드를 간단하게 시도합니다. 두 레이어가 포함 된 장면을 배치했기 때문에 이것이 내 HUD 레이어에 있더라도 내 Menu 버튼이 움직이는 이유라고 가정합니다. 내가 어쩌면 이런 일이 라인을CCNode Hud, 허드 역할을하지 않고 "장면으로 스크롤"
[self setCenterOfScreen: mainChar.position];
을 변경해야 할 것이라고 생각을 수정하려면 :
[gameLayer setCenterOfScreen: mainChar.position];
그러나 나는이 얻을 : 없음 볼 수
여기를 @ CCNode의 인터페이스는 셀렉터를 선언한다. 'setCenterOfScreen :'
은 GameScene (나는 문제가 생각하는 곳 주석)입니다 :
+ (GameScene *)scene
{
return [[self alloc] init];
}
// -----------------------------------------------------------------------
- (id)init
{
self = [super init];
if (!self) return(nil);
CGSize winSize = [CCDirector sharedDirector].viewSize;
self.userInteractionEnabled = YES;
self.theMap = [CCTiledMap tiledMapWithFile:@"AftermathRpg.tmx"];
self.contentSize = theMap.contentSize;
CCNode *gameLayer = [CCNode node];
gameLayer.userInteractionEnabled = YES;
gameLayer.contentSize = self.contentSize;
[self addChild:gameLayer];
[gameLayer addChild:theMap z:-1];
self.mainChar = [CCSprite spriteWithImageNamed:@"mainChar.png"];
mainChar.position = ccp(200,300);
[gameLayer addChild:mainChar];
// POSSIBLY WHY BOTH LAYERS ARE SHIFTING, RATHER THEN HUD STANDING STILL,
// I essentially want the gameLayer to be centered on screen, not both.
// I tried [gameLayer setCenterOfScreen: mainChar.position] but got error posted above
[self setCenterOfScreen: mainChar.position];
CCNode *hudLayer = [CCNode node];
hudLayer.userInteractionEnabled = YES;
hudLayer.position = ccp(winSize.width * 0.9, winSize.height * 0.9);
[self addChild:hudLayer];
CCButton *backButton = [CCButton buttonWithTitle:@"[ Menu ]" fontName:@"Verdana-Bold" fontSize:18.0f];
backButton.positionType = CCPositionTypeNormalized;
backButton.position = ccp(0.85f, 0.95f); // Top Right of screen
[backButton setTarget:self selector:@selector(onBackClicked:)];
[hudLayer addChild:backButton];
return self;
}
하지만 난 그냥 얻을 :
나는 장면을 설정하는 것입니다 방법에 그냥 혼란, 처음에 2를 가지고
레이어 - HUD처럼 오른쪽 상단에 위치를 유지하는 레이어와 게임 플레이를위한 장면으로 스크롤하는 레이어가 있습니다.