我一直在尝试调用下面的函数。似乎每当在函数playNote中我试图访问我作为参数(myNum)传递的对象时,它总是崩溃。我很新,我可能不明白如何通过 CCCallFuncND 传递参数。感谢所有评论。
这是传递参数myNum的调用:
id action2 = [CCCallFuncND actionWithTarget:self selector:@selector(playNote:data:) data:(NSNumber *)myNum];
这是整个块:
- (void)muteAndPlayNote:(NSInteger)noteValue :(CCLayer*)currentLayer
{
myNum = [NSNumber numberWithInteger:noteValue];
NSLog(@"Test the number: %d", [myNum integerValue]);
id action1 = [CCCallFunc actionWithTarget:self selector:@selector(muteAudioInput)];
id action2 = [CCCallFuncND actionWithTarget:self selector:@selector(playNote:data:) data:(NSNumber *)myNum];
id action3 = [CCDelayTime actionWithDuration:3];
id action4 = [CCCallFunc actionWithTarget:self selector:@selector(unmuteAudioInput)];
[currentLayer runAction: [CCSequence actions:action1, action2, action3, action4, nil]];
}
NSLog 从不显示它在此行崩溃的任何内容。
- (void) playNote:(id)sender data:(NSNumber *)MIDInoteValue
{
NSLog(@"Test number 2: %d", [MIDInoteValue integerValue]);
int myInt = [MIDInoteValue floatValue];
[PdBase sendFloat: 55 toReceiver:@"midinote"];
[PdBase sendBangToReceiver:@"trigger"];
}