在這個動畫中的位置:在動畫過程中防止Cocos2D觸摸?
- (void)ccTouchesBegan:(NSSet*)touches withEvent:(UIEvent*)event {
self.isTouchEnabled = NO;
if (scoreLabel.opacity == 225) {
NSLog(@"fadeOut");
CCSequence *fadeOut = [CCSequence actions:[CCFadeOut actionWithDuration:0.5], [CCCallFuncN actionWithTarget:self
selector:@selector(enableTouches)], nil];
[scoreLabel runAction:fadeOut];
[livesLabel runAction:[[fadeOut copy] autorelease]];
}
else {
NSLog(@"fadeIn");
CCSequence *fadeIn = [CCSequence actions:[CCFadeIn actionWithDuration:0.5], [CCCallFuncN actionWithTarget:self
selector:@selector(enableTouches)], nil];
[scoreLabel runAction:fadeIn];
[livesLabel runAction:[[fadeIn copy] autorelease]];
}
}
我想簡單地淡出/在標籤中。但事情是,我想要確保這個方法在標籤動畫時不會被調用。
如果你在代碼看,我試圖通過調用此方法,這樣做:
- (void)enableTouches {
NSLog(@"ET");
self.isTouchEnabled = YES;
}
但它似乎並沒有工作。如果我在標籤製作動畫時觸摸屏幕,則會在中途動畫化動畫,並且不會執行我想要的操作。
任何想法?
謝謝!
另一種方法是使用獨立的BOOL變量來控制在標籤動畫時是否忽略新的觸摸。 – LearnCocos2D