ios - SKSpriteNode.centerRect 不适用于 SKTextureAtlas
问题描述
我正在使用以下代码将 SKSpriteNode 添加到我的场景对象中。
let atlas = SKTextureAtlas(named: "Ubiquity")
let node = SKSpriteNode(texture: atlas.textureNamed("roundedBorder"))
node.zPosition = 2000
node.centerRect = CGRect(x: 0.4, y: 0, width: 0.2, height: 1)
addChild(node)
毕竟,我的纹理看起来是扭曲的(请参阅附加的图像错误的图像)但是,如果我删除node.centerRect
设置或将我的图像直接以下面的方式放入 xcasset
let node = SKSpriteNode(texture: SKTexture(imageNamed: "ubiquity-roundedBorder"))
node.zPosition = 2000
node.centerRect = CGRect(x: 0.4, y: 0, width: 0.2, height: 1)
addChild(node)
一切都按预期工作(请参阅附加的另一个图像正确的图像)
解决方案
我看到了同样的行为。这看起来像一个错误。
推荐阅读
- javascript - 如何将对象数组转换为自定义分组数组
- jquery - 如何用jQuery中的数组项替换部分字符串?
- python - SelectField WTForms 未在提交表单时返回所选值
- javascript - 如何在单击表格时获取特定行的单元格的位置
- excel - 如何从两个数组中找到缺失值
- c# - 使用 xpath 从使用节点前缀的 xml 中提取对象
- python - 如何在python中的小波阈值中设置要处理的信号的阈值
- javascript - 如何以数据表形式显示我的 (childData) 数组数据?
- javascript - 如何慢慢淡出彩色框?
- c# - 如何减少构造函数中的参数数量,其中一半是为基类提供的