2014-07-24 6 views
-2

xcode에서 플랫폼 게임을 만들려고하는데, 처음으로이 프로젝트에 착수했습니다.이 오류를 보았습니다. "셀렉터 'generatorWithWorld에 대한 알려진 클래스 메서드가 없습니다. :셀렉터 'generatorWithWorld :'에 대한 알려진 클래스 메소드가 없습니다.

// 
// MyScene.h 
// The Adventure of Colin The Sloth 
// 

// Copyright (c) 2014 SunnersCorp. All rights reserved. 
// 

**#import <SpriteKit/SpriteKit.h> 
#import "HSWorldGenerator.h"** 

@interface MyScene : SKScene 

@end 

MyScence.m : ' "나는 또한 오류를 받고 있어요"에 대한 눈에 띄는 @interface'HSWorldGenerator 이것은 MyScene.h 코드입니다

" '채우기'선택기를 선언하지 ' :

// 
// MyScene.m 
// The Adventure of Colin The Sloth 
// 
// Created by Harpreet Sunner on 24/07/2014. 
// Copyright (c) 2014 SunnersCorp. All rights reserved. 
// 

#import "MyScene.h" 
#import "HSSloth.h" 


@interface MyScene() 
@property BOOL isStarted; 
@property BOOL isGameOver; 
@end 

@implementation MyScene 
{ 
    HSSloth *Sloth; 
    SKNode *world; 
    HSWorldGenerator *generator; 
} 

-(id)initWithSize:(CGSize)size {  
    if (self = [super initWithSize:size]) { 
     /* Setup your scene here */ 
     self.anchorPoint = CGPointMake (0.5, 0.5); 
     self.backgroundColor = [SKColor colorWithRed:0.15 green:0.15 blue:0.3 alpha:1.0]; 

     world = [SKNode node]; 
     [self addChild:world]; 

     generator = [HSWorldGenerator generatorWithWorld:world]; **THIS IS WHERE I GET THE FIRST ERROR** 
     [self addChild:generator]; 
     [generator populate]; **THIS IS WHERE I GET THE SECOND ERROR** 


     Sloth = [HSSloth Sloth]; 
     [world addChild:Sloth]; 
    } 

    return self; 
} 

- (void)start 
{ 
    self.isStarted = YES; 
    [Sloth start]; 
} 

-(void)clear 
{ 
    NSLog(@"clear method called"); 
} 

- (void)gameOver 
{ 
    NSLog(@"gameOver method called"); 
} 

- (void)didSimulatePhysics 
{ 
    [self centerOrNode:Sloth]; 
} 

- (void)centerOrNode:(SKNode *)node 
{ 
    CGPoint postionInScene = [self convertPoint:node.position fromNode:node.parent]; 
    world.position = CGPointMake(world.position.x - postionInScene.x, world.position.y); 
} 

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { 
    if (!self.isStarted) 
     [self start]; 
    else if (self.isGameOver) 
     [self clear]; 
    else 
     [Sloth jump]; 

} 

-(void)update:(CFTimeInterval)currentTime { 
    /* Called before each frame is rendered */ 
} 

@end 

HSWorldGenerator.h :

// 
// HSWorldGenerator.h 
// The Adventure of Colin The Sloth 
// 
// Created by Harpreet Sunner on 24/07/2014. 
// Copyright (c) 2014 SunnersCorp. All rights reserved. 
// 

#import <SpriteKit/SpriteKit.h> 


@interface HSWorldGenerator : SKNode 

+ (id)generatorWithWorld:(SKNode *)world; 
- (void)populate; 
- (void)generate; 


@end 

HSWorldGenerator.m :

// 
// HSWorldGenerator.m 
// The Adventure of Colin The Sloth 
// 
// Created by Harpreet Sunner on 24/07/2014. 
// Copyright (c) 2014 SunnersCorp. All rights reserved. 
// 

#import "HSWorldGenerator.h" 

@interface HSWorldGenerator() 
@property double currentGroundX; 
@property double currentObstacleX; 
@property SKNode *world; 
@end 

@implementation HSWorldGenerator 

+ (id)generatorWithWorld:(SKNode *)world 
{ 
    HSWorldGenerator *generator = [HSWorldGenerator node]; 
    generator.currentGroundX = 0; 
    generator.currentObstacleX = 400; 
    generator.world = world; 
    return generator; 
} 

- (void)populate 
{ 
    for (int i = 0; 1 <3; i++) 
     [self generate]; 
} 

- (void)generate 
{ 
    SKSpriteNode *ground = [SKSpriteNode spriteNodeWithColor:[UIColor greenColor] size:CGSizeMake(self.scene.frame.size.width, 100)]; 
    ground.position = CGPointMake(self.currentGroundX, -self.scene.frame.size.height/2 + ground.frame.size.height/2); 
    ground.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:ground.size]; 
    ground.physicsBody.dynamic = NO; 
    [self.world addChild:ground]; 

    self.currentGroundX += ground.frame.size.width; 

    SKSpriteNode *obstacle = [SKSpriteNode spriteNodeWithColor:[UIColor redColor] size:CGSizeMake(40, 70)]; 
    obstacle.position = CGPointMake(self.currentObstacleX, ground.position.y + ground.frame.size.height/2 + obstacle.frame.size.height/2); 
    obstacle.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:obstacle.size]; 
    obstacle.physicsBody.dynamic = NO; 
    [self.world addChild:obstacle]; 

    self.currentObstacleX += 250; 

} 
@end 

사람이 필자가 잘못한 걸 말해 주 시겠어요 내가이, 내가 너무 많이 감사하겠습니다 해결하는 방법에 대해 설명합니다.

감사합니다!

+0

문제 및 해결 방법을 설명하는 관련 코드 및 질문을 게시하십시오. 사람들은 무작위 프로젝트를 다운로드하고 그것을 통해 파헤쳐 볼 가능성이 없습니다. – mc01

+0

ive 님이 지금 편집하셨습니다. 알려 주셔서 감사합니다. 나는 당신이 내 문제를 이해하고 나를 도울 수있는 방법. – HappyHarpreet

답변

0

#import HSWorldGenerator.h이 MyScene.h 파일에 있는지 확인하십시오. 클래스 메서드를 찾을 위치를 알 수 없다는 오류가 표시됩니다. MyScene.h에서 헤더를 가져 오려는 위치와 비슷하게 보이지만 그 행을 주석 처리하는 추가 '**'가 있습니다.

+0

여분의 ** 실제 코드에서 arent, 나는 그 질문을 쓸 때 실수로 넣은 것 같아요 ...하지만 ive는 MyScence.h 파일을 체크하고 거기에있는 모든 것은 괜찮습니다.하지만 왜 그 일을하는지 모릅니다. – HappyHarpreet

+0

흠 ... 그런 경우 코드는 클래스 이름 및 클래스 메서드를 잘 인식해야하는 것처럼 보입니다 ... 프로젝트를 "정리"할 수 있습니까? 또는 HSWorldGenerator.h를 MyScene.m으로 가져 오십시오. MyScene.h에 다른 종속성을 알릴 필요가 없습니다. 그것들이 작동하지 않는다면, 내가 제안 할 수있는 것은 Xcode를 닫거나 다시 시작하는 것입니다 - 때로는 단지 import 문을 인식하기를 거부하기 때문에 - 이전에 실행했습니다. – mc01

+0

나는 프로젝트를 청소하려고했지만 운이 전혀 없다. 그리고 귀하의 MyScene.m에 HSWorldGenerator.h 가져 오기 시도하고 여전히 아무것도 수정하지 않습니다. 나는 그것을 닫았지만 여러 번 다시 시작했지만 여전히 운이 없다. – HappyHarpreet

관련 문제