作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在 cocos2d 中,曾经有一个 TextureMgr 方法(异步),可以让您加载图像以供以后使用。现在当我使用 TextureMgr 时,它说它是未声明的。它被弃用了吗?我在 .99.5 上。如果它不再可用,用什么代替它?有什么可以做与这条线相同的事情吗?
[[TextureMgr sharedTextureMgr] addImageAsync:...NSString goes here... target:self selector:@selector(method:)];
最佳答案
看看 CCTextureCache
http://www.cocos2d-iphone.org/api-ref/0.99.5/interface_c_c_texture_cache.html
也许它是你正在寻找的。
当您创建任何带有纹理的对象时会使用此缓存:例如 sprite。您可以使用它来预缓存您的图像。
编辑:
CCTextureCache 用于创建带有纹理的 ang 对象,正如我所说 - 因此,如果纹理已经在缓存中,那么如果您先加载纹理然后创建对象,则元素创建要快得多。
例如,如果您正在编写这样的代码:id sprite = [CCSprite spriteWithFile: @"my-file.png"]
并且 @"my-file.png"纹理不在缓存中,它将首先加载并且需要一些时间(比创建对象要多得多)。
如果您正在编写这样的代码:
id sprite1 = [CCSprite spriteWithFile: @"my-file.png"];
id sprite2 = [CCSprite spriteWithFile: @"my-file.png"];
[[CCTextureCache sharedTextureCache] addImage: @"my-file.png"];
关于image - TextureMgr 怎么了?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4686707/
在 cocos2d 中,曾经有一个 TextureMgr 方法(异步),可以让您加载图像以供以后使用。现在当我使用 TextureMgr 时,它说它是未声明的。它被弃用了吗?我在 .99.5 上。如果
我是一名优秀的程序员,十分优秀!