.Netで、イベントを持つオブジェクトがある場合、デリゲートを介してそのイベントを処理するために登録できます。
void Test()
{
Button button = new Button();
button.Click += new EventHandler(OnClick);
}
void OnClick(object sender, EventArgs e)
{
text1.Text = "The Button Was Clicked";
}
Objective-Cでこの種のことを行うにはどうすればよいですか?具体的には、SneakyButtonのccTouchEndedを処理しようとしています。私はそれがこのようなものになるだろうと思いました:
SneakyButton* mybutton = [SneakyButton button];
[mybutton ccTouchEnded:self.onButtonDown];
- (void)onButtonDown:(UITouch *)touch withEvent:(UIEvent *)event
{
CCLOG(@"The Button Was Clicked");
}