我需要在CCSpeed延遲後調用函數,以便動態更改速度。據我所知,我不能在CCSequence中使用CCSpeed,所以我嘗試在CCSpeed內部使用CCSequence(CCDelayTime,CCCallFuncND,nil),這似乎也不起作用。任何人有任何建議?在我的BackgroundLayer類,我有一個NSNumber * multiplierSpeed;我有一個NSNumber * multiplierSpeed; :Cocos2D CCSpeed延遲後調用函數
@interface BackgroundLayer : CCLayer {
NSNumber *multiplierSpeed;
}
@property (nonatomic, retain) NSNumber *multiplierSpeed;
-(void)rotateWorldAndSwapIn:(id)sender data:(int)frame;
@end
而且在我的實現:
@synthesize multiplierSpeed;
-(id)init {
self = [super init];
if (self != nil) {
//...
multiplierSpeed = [NSNumber numberWithFloat:1.0f];
CCSpeed *delay = [CCSpeed actionWithAction:[CCSequence actions:[CCDelayTime actionWithDuration:20],[CCCallFuncND actionWithTarget:self selector:@selector(rotateWorldAndSwapIn:data:) data:(void*)3], nil] speed:1.0f];
[delay setTag:10];
[self runAction:delay];
//...
}
}
-(void)rotateWorldAndSwapIn:(id)sender data:(int)frame {
CCLOG(@"test"); //This is fine
CCLOG(@"multiplierSpeed=%f",[multiplierSpeed floatValue]); //Crashes here
//...
}
我收到此錯誤:
上callbackMethod_(targetCallback_,selector_,TARGET_,data_中)EXC_BAD_ACCESS;
CCActionInstant.m文件中。
另外,是否因爲CCSpeed環繞CCCallFuncND,它沒有延遲,這是拋出這個錯誤?如果是這樣,你有其他建議嗎?
感謝您的幫助!
Thanks!這樣的noob錯誤,我感謝你的幫助! – Cody 2012-04-29 18:53:33