iOS自定义SKShapeNode无法[自我添加子对象:myObject]

iOS自定义SKShapeNode无法[自我添加子对象:myObject],ios,sprite-kit,addchild,skshapenode,Ios,Sprite Kit,Addchild,Skshapenode,我有一个从SKShapeNode继承的自定义类,我无法成功地[self addChild:myObject] 例如,这段代码可以工作,并且接近我想要的,但是它实际上并没有创建定制的SKShapeNode。makeBall方法中的第一行是我想要更改的内容 #import "SpriteMyScene.h" #import "Balls.h" @interface SpriteMyScene() { SKShapeNode *ball; } @end @implementat

我有一个从SKShapeNode继承的自定义类,我无法成功地[self addChild:myObject]

例如,这段代码可以工作,并且接近我想要的,但是它实际上并没有创建定制的SKShapeNode。makeBall方法中的第一行是我想要更改的内容

#import "SpriteMyScene.h"
#import "Balls.h"

@interface SpriteMyScene() {
        SKShapeNode *ball;  
}
@end

@implementation SpriteMyScene

- (void)didMoveToView:(SKView *)view {
    self.backgroundColor = [SKColor whiteColor];

    [self setupBalls];

}

- (void)setupBalls {

    ball = [self makeBall];
    ball.position = CGPointMake(self.frame.size.width / 2, self.frame.size.height - 30);
    [self addChild:ball];
}

-(SKShapeNode *)makeBall {
    ball = [[SKShapeNode alloc] init];  //I want this... ball = [[Balls alloc] init];

    CGMutablePathRef myPath = CGPathCreateMutable();
    CGPathAddArc(myPath, NULL, 0, 0, 10, 0, M_PI*2, YES);

    ball.path = myPath;
    ball.fillColor = [SKColor redColor];


    return ball;
}


//I have this
ball = [[SKShapeNode alloc] init];  

//I want this... 
ball = [[Balls alloc] init];
在-(SKShapeNode*)makeBall方法中,我想实际分配一个从SKShapeNode继承的Ball对象,如下面的Ball.h中所示

//works
         ball = [[SKShapeNode alloc] init];  
//doesn't work... but this is what I want
         ball = [[Balls alloc] init];
//球

#import <SpriteKit/SpriteKit.h>

@interface Balls : SKShapeNode

@end

调用
self=[super init]谢谢谢谢谢谢!!!。成功了。你能帮我理解为什么要调用它吗?你需要初始化超类。总是。
#import "Balls.h"

@interface Balls () {

    bool isGoingRight, ballColided, ballTurned;

}
@end

@implementation Balls


-(id)init {


    if (self = [super init]){

        NSLog(@"Ball created");

        isGoingRight = false;
        ballColided = false;
        ballTurned = false;

    }
    return self;
}

@end