如果我创建这样的按钮:
CCMenuItemImage *okBtn = [CCMenuItemImage itemWithNormalImage:@"gameOkBtn.png"
selectedImage:@"gameOkBtnPressed.png"
block:^(id sender)
{
//actions
}];
我怎样才能在新闻和发布时播放声音?在常规的 iOS 开发中,我可以继承 UIButton 并为 UIControl 事件添加选择器。
编辑:这是子类
@implementation CCMenuItemImageSound
- (void)selected{
[super selected];
[[SoundManager sharedManager] playSound:kSoundButtonDown volume:0.5];
}
- (void)unselected{
[super unselected];
//this method gets called twice when you release the button
[[SoundManager sharedManager] playSound:kSoundButtonUp volume:0.5];
}
@end