预加载 SKTextures/SKTextureAtlas 混乱
Preloading SKTextures/SKTextureAtlas confusion
我已经阅读了此处关于此主题的所有帖子,其中 none 似乎回答了我的问题。
我的问题是 SKTexture/SKTextureAtlas 什么时候加载到内存中?
根据我的阅读,您需要对使用 [SKTexture preloadTextures:
withCompletionHandler:] 这样它就不会随 ARC 一起释放,这对我来说很有意义,因为当没有人保留它时,该对象将在方法结束时被释放。我不明白的是,带有保留它的强指针的 SKTexture 是如何不加载到内存中的,这不会使 [SKTexture preloadTextures: withCompletionHandler:] 变得多余和不必要,因为纹理已经加载到内存中了。我显然遗漏了一些东西,所以任何见解都会很棒。
干杯!
SKTexture Class Reference是这样解释的:
The texture data is loaded when:
The size method on the texture object is called.
Another method is called that requires the texture’s size, such as creating a new SKSpriteNode object that uses the texture object.
One of the preload methods is called (See Preloading the Texture Data.)
The texture data is prepared for rendering when:
A sprite or particle that uses the texture is part of a node tree that is being rendered.
Once the SKTexture object is ready for rendering, it stays ready until all strong references to the texture object are removed.
我已经阅读了此处关于此主题的所有帖子,其中 none 似乎回答了我的问题。
我的问题是 SKTexture/SKTextureAtlas 什么时候加载到内存中?
根据我的阅读,您需要对使用 [SKTexture preloadTextures: withCompletionHandler:] 这样它就不会随 ARC 一起释放,这对我来说很有意义,因为当没有人保留它时,该对象将在方法结束时被释放。我不明白的是,带有保留它的强指针的 SKTexture 是如何不加载到内存中的,这不会使 [SKTexture preloadTextures: withCompletionHandler:] 变得多余和不必要,因为纹理已经加载到内存中了。我显然遗漏了一些东西,所以任何见解都会很棒。
干杯!
SKTexture Class Reference是这样解释的:
The texture data is loaded when:
The size method on the texture object is called.
Another method is called that requires the texture’s size, such as creating a new SKSpriteNode object that uses the texture object.
One of the preload methods is called (See Preloading the Texture Data.)
The texture data is prepared for rendering when:
A sprite or particle that uses the texture is part of a node tree that is being rendered.
Once the SKTexture object is ready for rendering, it stays ready until all strong references to the texture object are removed.