SpriteKit TouchesMoved并阻止下拉菜单iOS

时间:2014-08-24 13:37:44

标签: ios sprite-kit touchesmoved

我正在使用iOS 7的SpriteKit来创建一个游戏,让一艘船在纵向模式下在屏幕的垂直一侧上下移动,以触摸移动方法对触摸作出反应。我遇到了一个问题,因为出于某种原因,模拟器顶部的下拉菜单显示菜单,当我向上移动时,我的手指仍然按住。问题似乎只发生在模拟器中。当我触摸屏幕移动我的船时,有没有办法防止显示通知下拉菜单?我的方法如下。

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    for (UITouch *touch in touches) {
        CGPoint location = [touch locationInNode:self];
        CGPoint newPosition = CGPointMake(heroShip.size.width / 2, location.y);

        // stop the paddle from going too far)
        if (newPosition.y < (heroShip.size.height / 2) + 100) {
            newPosition.y = (heroShip.size.height / 2) + 100;
        }
        if (newPosition.y > self.size.height - (heroShip.size.height/2) - 100) {
            newPosition.y = self.size.height - (heroShip.size.height/2) - 100;
        }

        heroShip.position = newPosition;
    }
}

谢谢, 格雷格

0 个答案:

没有答案