Questions tagged [cctexturecache]

CCTextureCache: Singleton texture manager used in Cocos2d game engine.

Singleton texture manager used in Cocos2d game engine, that loads texture only once and handles all loading and releasing of openGL texture.

Here is full Api reference.

16 questions
3
votes
1 answer

Cocos2d 2.0: when is good practice to "purge" caches?

Is it good practice to call the following "purge" methods at the beginning of each Scene? And if not when should I call them and is there any tutorial in explaining when to use each call? Am I missing something? [CCTextureCache…
2
votes
2 answers

cocos2d change sprite texture

I want to change a sprite texture with another texture from a sprite sheet //normal sprite character = [CCSprite spriteWithSpriteFrameName:@"char1.png"]; //change texture [character setTexture:[[CCTextureCache sharedTextureCache] addImage:[CCSprite…
Hassy31
  • 2,793
  • 3
  • 21
  • 37
2
votes
1 answer

CCParticleFire and CCParticleSystemQuad file not loading

I am trying to create particle effects like this: emitter = [[CCParticleSystemQuad alloc] initWithTotalParticles:45]; [emitter setEmitterMode: kCCParticleModeGravity]; emitter.position = ccp(100, 100); emitter.texture=[[CCTextureCache…
bluestunt
  • 479
  • 4
  • 11
2
votes
3 answers

Cocos2d. Load and store images correctly?

There are a lot of answers for this question. But all of them are incorrect! For example if I have created a CCLayer object with one CCSprite object. I have 3 textures and I want to switch between them on every touch. For example I will use…
Gargo
  • 1,135
  • 1
  • 10
  • 21
1
vote
1 answer

Cocos2d. Why loading texture asynchronously retains it?

I have discovered a weird thing - CCTexture2D object gets retained when it is loaded asynchronously either by usage of addImageAsync:(NSString*)path withBlock:(void(^)(CCTexture2D *tex))block or -(void) addImageAsync: (NSString*)path…
Andrey Chernukha
  • 21,488
  • 17
  • 97
  • 161
1
vote
0 answers

'NSInternalInconsistencyException: Do not initialize the TextureCache before the Director'

To find a solution I have gone thru this similar link: TextureCache Error from Cocos2d when integrated into UIKit App but seems like it is dealing with this error in a different context.. Question: I have a UIKit project integrated with Cocos2d.…
iSeeker
  • 776
  • 1
  • 8
  • 24
1
vote
0 answers

Couldn't add image fire.png in CCTextureCache, but fire.png is in project..?

I searched all over the internet for an answer to this but it's driving me crazy .. I'm trying to create a CCParticleSun or CCParticleEffect.. Now I know these need the fire.png and fire.pvr found in the resources folder for cocos2d.. I Have…
0
votes
1 answer

Updating a CCTexture2D from a BatchNode

After I completed my testing, I have moved my images over to a spritesheet. I loaded up the batchnode with the appropriate files and my images load just fine. But I am running into an issue of swapping the textures out. When the images were…
user-44651
  • 3,924
  • 6
  • 41
  • 87
0
votes
0 answers

Cocos2D CCTextureCache stays in memory

I load images in a asynchronous way, for a scroller, using addImageAsync. I start profiling, and saw some memory issue, images stayed in memory. Then I decided to compare addImageAsync vs spriteWithFile, with loading and directly unloading…
0
votes
1 answer

Cocos2d-x TMX maps sharing Texture image file with game sprites?

I am using cocos2d-x 2.1.4 and would like to use the same image file e.g. spritesheet.png for the tiles on a tmx map built using Tiled Map Editor as well as; in-game sprites, which I usually make the spritesheet using TexturePacker. The reason…
blufiro
  • 310
  • 2
  • 10
0
votes
1 answer

Animate CCTexture2D using spritesheet

I have made spritesheet in Zwoptex , I know TexturePacker is better than this but i have just started with cocos2d iphone, so haven't purchase that. I have made CCTexture2D using following code. texture = [[CCTextureCache sharedTextureCache]…
Renaissance
  • 564
  • 5
  • 26
0
votes
1 answer

How to add CCTexture2D to CCTextureCache cocos2d

I have some encrypted images.. They are pretty heavy, so I want to preload them by adding them to CCTextureCache. However CCTextureCache does not accept CCTexture2D as a parameter.. What can I do? CCTexture2D *img = [[[CCTexture2D alloc]…
user123
  • 2,711
  • 5
  • 21
  • 25
0
votes
1 answer

UIImage to CCSprite cocos2d v 2.0

Moved to version 2.0 of Cocos2D but I'm trying to find a workaround solution to convert UIImage to CCSprite, previous one like: CCTexture2D *texture = [[[CCTexture2D alloc] initWithImage:tempImage] autorelease]; self.spriteImage =…
el.severo
  • 2,202
  • 6
  • 31
  • 62
0
votes
1 answer

Cocos2D 2.0 - Changing color of a CCParticle

So after messing around with my game, there's a thing that I wanted to share with you that I discovered about CCParticle. How do I change the color of the particles in a CCParticleSystem? When I was on cocos 1.x, I could change it with startColor,…
RaphBlanchet
  • 575
  • 6
  • 23
0
votes
0 answers

OpenGL ES - glReadPixels vs TextureCached

I need to read the pixel data from the frame buffer in OpenGL ES 2.0. I know that can be done easily with glReadPixels but since iOS 5 we can use the TextureCached objects for faster reading. I have implemented the solution proposed by Brad Larson (…
1
2