gpt4 book ai didi

ios - 预加载 SKTextures/SKTextureAtlas 困惑

转载 作者:行者123 更新时间:2023-11-29 10:30:42 25 4
gpt4 key购买 nike

我已经阅读了此处关于此主题的所有帖子,但似乎都没有回答我的问题。

我的问题是 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.

关于ios - 预加载 SKTextures/SKTextureAtlas 困惑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29830806/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com