将UIKit坐标转换为SpriteKit坐标 [英] Convert UIKit coordinates to SpriteKit coordinates
问题描述
我正在尝试将普通uikit坐标(左上角的原点,宽度和高度向右和向下)转换为Sprite Kit坐标(原点位于节点的中心,左和下为负,右和上为正)./p>
有人知道该怎么做吗?不幸的是,我无法解决此问题,因为我正在使用QuartzCore在SKNode上进行绘制.如果不进行转换,我将真正摆脱图纸.
根据文档, SKView
具有用于在节点坐标系之间来回转换.
I am trying to convert normal uikit coordinates (top left origin, width and height go right and down) to Sprite Kit coordinates (origin is at center of node, left and down are negative, right and up are positive).
Does anyone know how to do this? Unfortunately I can't work around this to my knowledge because I am using QuartzCore for drawing on a SKNode. Without converting, I am getting really off drawings.
According to the docs, SKView
has methods for Converting Between View and Scene Coordinates.
Remember the scene is itself an SKNode
, so if you need to get from scene coordinates to a particular node coordinate system there's also the methods in Converting to and from the Node’s Coordinate System.
这篇关于将UIKit坐标转换为SpriteKit坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!