SKTexture 和 SpriteKit 中的 Sprite 之间的区别?

Difference between SKTexture and a Sprite in SpriteKit?

我正在学习 SpriteKit,但我不太了解精灵 (SKSpriteNode) 和纹理 (SKTexture) 之间的区别。我知道两者都是图像,"A SKSpriteNode ist a image which is drawn currently and a SKTexture only save the Data from a image to load it later in the Game so you save the image one Time and then you can put the texture in the SKSpriteNode when ever you want".

对吗?

感谢您的帮助 ;)

一个非常原始的例子

想想 UIKit 中的 UIImageUIImageView。第一个是图像,而第二个是可以添加到视图(在给定位置)并可以存储图像的 UI 元素。 SKTextureSKSpriteNode.

也会发生类似的情况

SKSpriteNode

首先是SKNode

它有一个 position、一个 rotation 角度、一个 scale 因子和一堆其他属性,包括一个 SKTexture。您可以添加一个 SKSpriteNode 作为 GameSceneSKScene 的子类)或场景内另一个节点的子节点。

如果将 SKSpriteNode 添加到场景中,则根据应用于 SKSpriteNode 的几何变换(位置、旋转、规模等...)。 如果 SKSpriteNode 超出屏幕边界或被另一个图形元素覆盖,则相关纹理不会在屏幕上呈现。

An SKSpriteNode is a node that draws a textured image, a colored square, or a textured image blended with a color. You can also provide a custom shader to create your own rendering effects.

SKTexture

基本上是位图格式的图片。事实上,您可以使用 UIImage 创建一个 SKTexture,并且可以将其转换为 SKSpriteNode.

A SKTexture NOT 位置、旋转角度或许多其他属性,您可以在 SKSpriteNode 中找到。它只是一个图像。

An SKTexture object is an image that can be applied to SKSpriteNode [...]. A texture object manages the texture data and graphics resources that are needed to render the image.