【问题标题】:iOS Touch Not Working On HoldiOS 触摸在保持时不起作用
【发布时间】:2012-11-29 10:23:53
【问题描述】:

提前为菜鸟问题道歉。 但我对 iOS 开发非常陌生。

我从这里学习了一个简单的 Pong 教程: http://www.technobuffalo.com/companies/apple/introduction-to-ios-development-programming-pong-part-4/

我已成功调试并让应用程序正常运行, 但我似乎只能在“重新触摸”屏幕时移动玩家拨片。

即在屏幕上按住时,拨片不跟随手指移动。

据我了解,以下是控制触摸事件的方法:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
self.gameState = kGameStateRunning;

if (location.x > 400) {
    CGPoint yLocation = CGPointMake(playerPaddle.center.x, location.y);
    playerPaddle.center = yLocation;
}
}

任何人都可以帮助阐明问题可能是什么吗?

非常感谢提前:)

【问题讨论】:

    标签: ios touch


    【解决方案1】:

    你错了!你不应该使用

    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
    

    顾名思义,这仅检测手指触摸屏幕。 你应该使用

    - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-02-06
      • 1970-01-01
      • 2017-05-14
      • 2017-06-11
      • 1970-01-01
      • 1970-01-01
      • 2013-08-28
      • 1970-01-01
      相关资源
      最近更新 更多