将 UIKit 坐标转换为 SpriteKit 坐标 [英] Convert UIKit coordinates to SpriteKit coordinates

查看:27
本文介绍了将 UIKit 坐标转换为 SpriteKit 坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将正常的 uikit 坐标(左上原点,宽度和高度向右和向下)转换为 Sprite Kit 坐标(原点在节点的中心,左和下是负数,右和上是正数).

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).

有人知道怎么做吗?不幸的是,据我所知,我无法解决这个问题,因为我正在使用 QuartzCore 在 SKNode 上绘图.没有转换,我真的很喜欢图纸.

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.

推荐答案

根据文档,SKView视图和场景坐标之间的转换.

记住场景本身就是一个SKNode,所以如果你需要从场景坐标到特定的节点坐标系,还有与节点坐标系相互转换.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆