0
switch 문 안에 sceneWithSize:
을 어떻게 사용할 수 없습니까? 스위치 케이스 밖에서 새로운 게임 장면의 객체를 만들면 잘 동작합니까? 그러나 사용자가 선택한 spriteNode
에 따라 게임 장면이 전환됩니다. 왜 이런 일이 벌어지고 있으며 내가하려는 일을하는 대체 방법이 있습니까? 당신은 변수 선언과 함께 case
을 시작할 수 없기 때문에메서드는 Switch 문에서 사용할 수 없습니까?
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
/* Called when a touch begins */
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInNode:self];
SKNode *node = [self nodeAtPoint:location];
NSLog(@"Level Selected: %@", node.name);
int x = [node.name intValue];
switch (x) {
case 1:
// if I move this code outside the switch statement it works?
LevelOne *newscene = [LevelOne sceneWithSize:self.size]; // here is where I get an expected expression error?
//[self.view presentScene:newscene transition:[SKTransition doorsOpenVerticalWithDuration:1]];
break;
default:
break;
}
}
기술 설명 : 여기 http://stackoverflow.com/questions/92396/why-cant-variables-be-declared-in-a- switch-statement – Cyrille
감사합니다. switch case 문에 대한 Xcode의 기본 코드 스 니펫을 비난합니다. P –