replacing a CCSprite with another: memory leaks?
I have a HellpWorld template.
i have a CCNode with a variable:
with an init function
added the CCNode as child in helloworld.m init
if i want to replace the image with another one using always a.
i have a method inside the CCNode that makes:
but nothing happens...
make it crash...
so i've tryed:
and it works, but i think it will have memory leaks because i have used alloc. correct me if i'm wrong.
but i don't know how to release the texture before loading another.
and why:
doesnt work?
thanks
i have a CCNode with a variable:
Code:
CCSprite *a;//in headerwith an init function
Code:
a=[CCSprite spriteWithFile:"a.png"];if i want to replace the image with another one using always a.
i have a method inside the CCNode that makes:
Code:
a=[CCSprite spriteWithFile:"b.png"];Code:
[a release];
a=[CCSprite spriteWithFile:"b.png"];so i've tryed:
Code:
[a setTexture: [[CCTexture2D alloc] initWithImage:[UIImage imageNamed: @"b.png"]];but i don't know how to release the texture before loading another.
and why:
Code:
a=[CCSprite spriteWithFile:"b.png"]thanks
the CCTextureCache handles the management of releasing and allocating textures.
thanks i'll try

