2011-07-22 81 views
0

在Xcode 4中獲取此錯誤。我正在閱讀一本使用0.99.5的書,我認爲我正在使用1.0.0框架for cocos2d。cocos2d語義問題

錯誤:語義問題:分配給來自不兼容的類型 'CGPoint'(又名 '結構CGPoint') '雙'

在這條線

playerVelocity = playerVelocity.x * dec + acceleration.x * sens; 

任何想法。

的完整代碼

float dec = 0.4f; //lower = quicker to change direction; 
float sens = 6.0f; //higher more sensitive; 
float maxVel = 100; 

playerVelocity = playerVelocity.x * dec + acceleration.x * sens; 

if(playerVelocity.x > maxVel) 
{ 

} 
else if(playerVelocity.x < - maxVel) 
{ 
    playerVelocity.x = - maxVel; 
} 

回答

0

playerVelocity是矢量,所以你應該賦值給它這樣的:

playerVelocity = ccp(playerVelocity.x * dec + acceleration.x * sens, 0); 

ccp宏將建立一個向量,你與兩個組件,您指定。我給出0作爲y分量,隨意根據需要更改此值。

0

所以playerVelocity是一個點,但是「playerVelocity.x * dec + acceleration.x * sens」是一個double。

您不能爲點指定雙精度值。

我想你的意思是, playerVelocity.x = playerVelocity.x * dec + acceleration.x * sens; ?