在SKScene
- (void)increaseScoreBy:(float)amount
{
score += amount;
scoreNode.text = [NSString stringWithFormat:@"Score:%1.0f", score];
}
在SKNode
MyScene *objmyscene;
[objmyscene increaseScoreBy:2];
我想从员工类(increaseScoreBy:
的子类)
SkNode
方法
答案 0 :(得分:0)
在员工类中,将父项的指针保存为场景。在创建员工对象时发送父指针。
// use this in employee class
+(id)initWithParent:(id)InParent
{
employee *obj = [employee alloc] init];
obj.parentNode = InParent
return obj;
}
//您可以访问MyScene对象员工类
MyScene *objmyscene = (MyScene*)self.parentNode;