0
有人知道爲什麼我永遠不會獲得我的數組的第一個值嗎?它總是從I + 1的指數,當我開始在for循環爲0,或1喜歡這裏:不是X = 44,控制檯說,X = 100:CGPoint數組中的索引從i + 1開始?
//at the top
#define kMaxHillKeyPoints 5
//in the .h:
CGPoint _hillKeyPoints[kMaxHillKeyPoints];
- (void)generatePath {
int _nVertices = 1;
_hillKeyPoints[_nVertices] = CGPointMake(44, 0);
_hillKeyPoints[_nVertices++] = CGPointMake(100, 75);
_hillKeyPoints[_nVertices++] = CGPointMake(50, 150);
_hillKeyPoints[_nVertices++] = CGPointMake(150, 225);
for(int i = 1; i < 4; i++) {
CCLOG(@" _hillKeyPoints[1].x : %f", _hillKeyPoints[1].x);
CCLOG(@"%i", i);
}
}
//output :
_hillKeyPoints[1].x : 100.000000 //why not x = 44 ?
你知道爲什麼嗎?我也清理了這個項目,但它並沒有改變任何東西。
感謝
謝謝kentoh,它現在可以工作!謝謝你的幫助! – Paul
歡迎您:) –