配列内のスプライトを追跡し、それらをレイヤーに追加および削除してから、最終的にそれらを配列からクリアしようとしています。
私は次のコードを使用しています:
Sprite * Trees[50];
Layer * Forest;
Forest = [Layer node];
Forest.isTouchEnabled = YES;
[self addChild:Forest z:30];
// do this a bunch of times
Trees[0] = [[Sprite spriteWithFile:@"mytree.png"] retain];
[Trees[0] setPosition:cpv(240,160)];
[Forest addChild:Trees[0] z:5];
そして、私が使用するツリーを破壊したいとき:
[Forest removeChild:Trees[0] cleanup:YES];
[Trees[0] release];
私の問題は、Instruments を見ると、そのメモリを再利用していないことです。スプライトを解放することでメモリが解放されると思いました。私はこれを完全に間違っていますか?