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
사람이 필자가 잘못한 걸 말해 주 시겠어요 내가이, 내가 너무 많이 감사하겠습니다 해결하는 방법에 대해 설명합니다.
감사합니다!
문제 및 해결 방법을 설명하는 관련 코드 및 질문을 게시하십시오. 사람들은 무작위 프로젝트를 다운로드하고 그것을 통해 파헤쳐 볼 가능성이 없습니다. – mc01
ive 님이 지금 편집하셨습니다. 알려 주셔서 감사합니다. 나는 당신이 내 문제를 이해하고 나를 도울 수있는 방법. – HappyHarpreet