gpt4 book ai didi

ios - SpriteKit 滚动 SKCameraNode 非常有问题

转载 作者:行者123 更新时间:2023-11-28 07:02:11 26 4
gpt4 key购买 nike

当我用我的代码滚动浏览这个场景时,它看起来非常有问题。一切都很快地跳来跳去,直到你放手。有更好的方法吗?

var lastTouch: CGPoint!
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
let touch : UITouch = touches.first!
lastTouch = touch.locationInNode(self)
}
override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) {
let touch : UITouch = touches.first!
let touchLocation : CGPoint = touch .locationInNode(self)
self.camera!.position = CGPointMake(self.camera!.position.x + (lastTouch!.x - touchLocation.x), self.camera!.position.y + (lastTouch!.y - touchLocation.y))
lastTouch = touchLocation;
}
override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
let touch : UITouch = touches.first!
let touchLocation : CGPoint = touch .locationInNode(self)
self.camera!.position = CGPointMake(self.camera!.position.x + (lastTouch!.x - touchLocation.x), self.camera!.position.y + (lastTouch!.y - touchLocation.y))
print(touches.count)
lastTouch = touchLocation;
}

如果真的有必要,我可以上传 gif/视频。这只是 SKCameraNode 的一个错误,因为它太新了?如果有人知道我做错了什么,我很乐意听到。谢谢!

编辑:Click here to see a video of the issue

最佳答案

我找到了答案,因为这是一个非常简单的错误。当相机节点移动时,您触摸的位置也会移动。我创建了一个随相机移动的节点,并获取触摸在该节点中的位置。

关于ios - SpriteKit 滚动 SKCameraNode 非常有问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31764613/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com