2014-01-27 2 views
-1

최근 스프라이트 키트 작업을 시작했습니다. 이제는 새로운 스프라이트 키트 프로젝트를 열었고 필요하지 않으므로 MyScene 클래스를 제거했습니다. 나는 지금이 일을하고 코드를 바꾼 PhyscisScene SKView의 내 자신의 하위 클래스를 만들었습니다 ViewController.m라인 24에서 ViewController.m : No known class method for selector 'sceneWithSize:'에이 오류가 발생했습니다 아래의 모든 클래스 파일이 잘 변경되었습니다. 워드 프로세서, sceneW 보면이상한 오류 "셀렉터 'sceneWithSize :'"에 대한 알려진 클래스 메서드가 없습니다.

ViewController.m

#import "ViewController.h" 
#import "PhysicsScene.h" 

@implementation ViewController 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    // Configure the view. 
    SKView * skView = (SKView *)self.view; 
    skView.showsFPS = YES; 
    skView.showsNodeCount = YES; 

    // Create and configure the scene. 
    SKScene * scene = [PhysicsScene sceneWithSize:skView.bounds.size]; 
    scene.scaleMode = SKSceneScaleModeAspectFill; 

    // Present the scene. 
    [skView presentScene:scene]; 
} 

- (BOOL)shouldAutorotate 
{ 
    return YES; 
} 

- (NSUInteger)supportedInterfaceOrientations 
{ 
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { 
     return UIInterfaceOrientationMaskAllButUpsideDown; 
    } else { 
     return UIInterfaceOrientationMaskAll; 
    } 
} 

- (void)didReceiveMemoryWarning 
{ 
    [super didReceiveMemoryWarning]; 
    // Release any cached data, images, etc that aren't in use. 
} 

@end 

PhysicsScene.m

#import "PhysicsScene.h" 

@implementation PhysicsScene 

- (id)initWithFrame:(CGRect)frame 
{ 
    self = [super initWithFrame:frame]; 
    if (self) { 
     // Initialization code 
    } 
    return self; 
} 

/* 
// Only override drawRect: if you perform custom drawing. 
// An empty implementation adversely affects performance during animation. 
- (void)drawRect:(CGRect)rect 
{ 
    // Drawing code 
} 
*/ 

@end 
+0

PhysicsScene 인터페이스 (아마도 PhysicsScene.h에 있음)에 + (id)와 같은 메서드가 포함되어 있습니까? sceneWithSize : (CGSize) size; ? 그렇지 않은 것 같은데. – danh

+0

@danh 아니,하지만 스프라이트 키트 용으로 만든 다른 프로젝트에도 포함되어 있지 않지만 컴파일 오류없이 컴파일된다. 또한 sceneWithSize는 프로젝트를 만들 때 이미 있던대로 수동으로 입력하면 안된다. – Mutch95

답변

3

PhysicsSceneSKView의 하위 클래스입니다. PhysicsSceneSKScene의 하위 클래스 여야합니다. 해결책은 PhysicsSceneSKScene의 하위 클래스로 변환하는 것이므로 사용하고자하는 것처럼 보입니다.

1

: 세드릭 말해 줄 수 ithSize는 SKView가 아닌 ​​SKScene의 클래스 메서드입니다.

관련 문제