4
當調試下面的代碼中,XPOS = 0,yPos = 0,怪異cocos2d的位置座標
CCNode* node = [birdsAlone objectAtIndex:nextInactiveBird];
NSAssert([node isKindOfClass:[BirdEntity class]], @"not a bird entity");
BirdEntity* bird = (BirdEntity*) node;
float birdHeight = CGRectGetHeight([bird boundingBox]);
float xPos = ([[CCDirector sharedDirector] winSize].width - 100) * CCRANDOM_0_1() + 50;
float yPos = ([[CCDirector sharedDirector] winSize].height + birdHeight/2.0f);
CGPoint location = ccp(xPos, yPos);
[[CCDirector sharedDirector] winSize]和birdHeight的值是什麼?在調試器中找不到 – Andrew 2011-03-14 22:36:48
。現在可以。我使用鏗鏘調試和分析,事實證明,birdAlone是零和節點是垃圾...我使用[CCArray arrayWithCapacity:20]而不是[[CCArray alloc] initWithCapacity],輸入太快^ _^ – John 2011-03-15 10:35:04
嘿,那裏,是你在「調試」還是「釋放」模式下調試?你不應該得到birdsAlone ==零...另外,請指定這段代碼放在哪裏的函數。是birdsAlone類的成員?輸入參數? – Goles 2011-03-20 04:34:32