我正在嘗試更改從SpriteBatchNode創建的精靈貼圖。從CCSpriteBatchNode更改精靈貼圖
[CCTexture2D setDefaultAlphaPixelFormat:kCCTexture2DPixelFormat_RGBA4444];
spritesBgNode = [CCSpriteBatchNode batchNodeWithFile:@"playingCards.pvr.ccz"];
[self addChild:spritesBgNode];
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"playingCards.plist"];
我搜索,發現使用
Texture2D *texture = [[Texture2D alloc] initWithImage:myUIImage]
[sprite setTexture: texture];
所以我的問題是例子:如何從我的batchNode文件中獲取的形象呢?或者我使用另一種方法來獲取對我的playingCards.pvr.ccz文件中的圖像的引用。
UPDATE
首先感謝您的響應。因此,我使用您提供的代碼片段將mySprite與King的圖像相關聯。但是我想改變精靈的紋理來顯示卡的背面(所以它可以面朝上或向下),我在CCSpriteBatchNode中都有這兩個圖像。
但正如你指出「你不能從batchNode形象」,所以我不能使用[[的Texture2D頁頭] initWithImage:myUIImage]
所以我去改變精靈的形象從正面朝下。
感謝
我已經更新了下面的答案以反映您的更新問題 – nash 2011-05-04 06:56:32
Tarek,請您指出下面的答案是否解決了問題? – nash 2011-05-06 08:49:44