67c*_*ies -1 inheritance objective-c instancetype sprite-kit skspritenode
我有一个自定义类,它是一个子类SKSpriteNode.我试图覆盖spriteNodeWithColor:size:返回的方法instancetype.我试试这个:
-(instancetype)initWithColor:(UIColor *)color size:(CGSize)size{
self.color = color;
self.size = size;
//do other setup stuff here
return self;
}
Run Code Online (Sandbox Code Playgroud)
但它每次都会崩溃.在此先感谢您的帮助
你需要打电话super:
- (instancetype)initWithColor:(UIColor *)color size:(CGSize)size {
self = [super initWithColor:color size:size];
if (self) {
// do other setup stuff here
}
return self;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
509 次 |
| 最近记录: |