【问题标题】:Performance difference between SKShapeNode and SKSpriteNodeSKShapeNode 和 SKSpriteNode 之间的性能差异
【发布时间】:2018-05-05 16:31:44
【问题描述】:

如果我想画一个简单的红色矩形,我应该使用SKShapeNode 还是SKSpriteNode?性能(渲染速度)有何不同?

是否有任何例外(例如应用透明度,或者可能创建physicsBody)?

我知道两者的主要目的是什么,但我不确定哪个在绘制简单红色方块时性能更好。

代码:

// Shape
let myShape = SKShapeNode(rectOf: CGSize(width: 100, height: 100))
myShape.fillColor = .red
myShape.strokeColor = .clear

// Sprite
let mySprite = SKSpriteNode(color: .red, size: CGSize(width: 100, height: 100))

【问题讨论】:

    标签: ios swift performance sprite-kit rendering


    【解决方案1】:

    SKSpriteNode 提供比 SKShapeNode 类更高的性能。 See documentation here

    如果要将物理体添加到 SKShapeNode,则应与 shapenode 点对齐。要获得更复杂的性能,请使用 SKSpriteNode。当难以使用纹理(可能是自定义形状)以及构建或显示调试信息时,SKShapeNodes 很有用。

    此外,使用 SKShapeNode 可以绘制/显示红色矩形。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-11-21
      • 2012-05-26
      • 2013-09-02
      • 2014-03-15
      • 2010-12-07
      • 2017-06-05
      • 2011-12-03
      • 2015-02-21
      相关资源
      最近更新 更多