如何解决移动SpriteNode时如何确保触摸位置与屏幕匹配
我正在尝试制作一款可以移动宝石的游戏。我的代码中的 gem 由 gemBase(灰色)所有,它由 GameScene 拥有。一切正常。
但是,我正在尝试添加一个功能,让用户可以切换到左手游戏。当他们这样做时,我将 gemBase 移到右侧,这会自动移动所有宝石。
然后发生的情况是,我的 touchLocation 偏向了我实际触摸屏幕的位置的右侧。这是所有权问题吗?我是否必须将所有者的任何触摸转换为实际屏幕?
override func touchesMoved(_ touches: Set<UITouch>,with event: UIEvent?){
guard touches.first != nil else { return }
if toggleHigh {highliteGem(theGem: myGems[0],clearall: true)}
if let touch = touches.first,let node = myGV.currentGem,node.isMoving == true {
let touchLocation = touch.location(in: self)
node.moved = true
print(touchLocation)
node.position = touchLocation
node.isMoving = true
node.inSlot = false
//addTrailToTwinkle(theNode: node)
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。