2014-06-20 58 views
0

SKScene誰能給我舉例skscene類的調用方法從sknode類

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

MyScene類的子類在SKNode

MyScene *objmyscene; 
[objmyscene increaseScoreBy:2]; 

Employee類的子類我想打電話從increaseScoreBy:方法員工分類(SkNode的子分類)

回答

0

在父級員工類別中保持指針爲場景。創建員工對象時發送父指針。

// use this in employee class 
+(id)initWithParent:(id)InParent 
{ 
    employee *obj = [employee alloc] init]; 
    obj.parentNode = InParent 
    return obj; 
} 

//你可以訪問MyScene對象Employee類

MyScene *objmyscene = (MyScene*)self.parentNode;