そのため、ほとんどのリソースを にプリロードしており、CCTextureCache
からスプライトを作成する方法を知りたいと思っていCCTextureCache
ます。一般に、私は通常 `CCSprite spriteWithFile` を実行することを知っていますが、キャッシュされたテクスチャにアクセスする方法がわかりません。
2 に答える
3
well
CCSprite *spr = [CCSprite spriteWithFile:@"theSprite.png"];
actually puts the texture in cache with the file name as key.
so
CCTexture2D * tex = [CCTextureCache sharedTextureCache:textureForKey:@"theSprite.png"];
will actually give you back the sprite's texture.
One last bit : before putting the texture in cache, the CCSprite constructor verifies if the cache already contains a texture with the key. If it does, it skips a whole bunch of steps and returns you the sprite constructed with the cached texture.
于 2013-04-16T16:55:10.507 に答える
0
これを試して:
CCTexture2D *pText = [CCTextureCache sharedTextureCache:textureForKey: @"(your picture filename)"];
CCSprite *pSprite = [CCSprite spriteWithTexture: pText];
ここでリファレンスを読んでください(リファレンスから必要なものはほとんどすべて入手できます):
http://www.cocos2d-iphone.org/api-ref/latest-stable/interface_c_c_sprite.html
于 2013-04-16T16:58:20.023 に答える