ユーザーがジョイスティックでプレイしているときに、中央のキャラクターを動かしている間に、画面の右下に触れて (2 回目のタッチ)、銃を発射できるようにするにはどうすればよいですか? 私は他の質問を見ましたが、まだ理解できません...
これは基本的にコードです....:
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
//make the touch point...
UITouch *touch = [[event allTouches]anyObject];
CGPoint point = [touch locationInView:touch.view];
if (//touching a certain area (on the joystick)) {
//do stuff
}
else if (point.x > 300 && point.y > 200) {
/fire method
}
}
では、基本的に touchesBegan を再度呼び出して CGPoint ポイントの位置を見つけ、fire メソッドを呼び出す必要があるかどうかを判断するにはどうすればよいでしょうか?
ありがとう
編集:
私はその2番目のオプションを実行しようとしましたが、これを実行しました:view controller.hで追加しました:
@interface fireView: UIView
@end
そして.mに次を追加しました:
@implementation fireView -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
NSLog(@"hi");
}
@end
....しかし、「こんにちは」をログ/出力しませんか?