0

在 MyScene 类的子类中SKScene

- (void)increaseScoreBy:(float)amount
{
    score += amount;
    scoreNode.text = [NSString stringWithFormat:@"Score:%1.0f", score];       
}

在员工类子类中SKNode

MyScene *objmyscene;
[objmyscene increaseScoreBy:2];

我想increaseScoreBy:从员工类(的子类SkNode)调用方法

4

1 回答 1

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;
于 2014-06-20T09:11:21.560 回答