Ios 将SKSpriteNode移动到SKTileMapNode上的特定磁贴

Ios 将SKSpriteNode移动到SKTileMapNode上的特定磁贴,ios,swift,sprite-kit,Ios,Swift,Sprite Kit,为了简单起见,假设我有一个SKSpriteNode和一个SKTileMapNode,如下所示 var background = childNode(withName: "Background") as! SKTileMapNode var player = SKSpriteNode(imageNamed: "player") as! SKSpriteNode 我想将播放机移动到背景中的行位置5和列位置8,最好的方法是什么?要开始,您可以检索指定磁贴的位置,并创建移动操作以在播放机节点上运行 l

为了简单起见,假设我有一个SKSpriteNode和一个SKTileMapNode,如下所示

var background = childNode(withName: "Background") as! SKTileMapNode
var player = SKSpriteNode(imageNamed: "player") as! SKSpriteNode

我想将播放机移动到背景中的行位置5和列位置8,最好的方法是什么?

要开始,您可以检索指定磁贴的位置,并创建移动操作以在播放机节点上运行

let destination = background.centerOfTile(atColumn: 8, row: 5)
let action = SKAction.move(to: destination, duration: 5)

player.run(action)

然后,您可以查看
UITapGestureRecognitizer
,以便玩家可以移动到您在地图上点击的位置

正是我需要的。非常感谢。