看看下面的代码:
CCSprite* testsprite = [CCSprite spriteWithFile:@"test.png"];
CCLOG(@"1. count: %d", [testsprite retainCount]);
[self addChild:testsprite];
CCLOG(@"2. count: %d", [testsprite retainCount]);
[testsprite runAction: [CCMoveTo actionWithDuration:3.0 position:CGPointMake(200.0, 200.0)]];
CCLOG(@"3. count: %d", [testsprite retainCount]);
这段代码的输出是:
1. count: 1
2. count: 2
3. count: 3
我想我明白这里发生了什么。问题如下:Cocos2D 何时(在哪些方法中)保留对象(在本例中为 testsprite)是否有经验法则?
再见,克里斯蒂安