【问题标题】:cocos2d semantic issuecocos2d 语义问题
【发布时间】:2011-07-23 02:43:58
【问题描述】:

在 Xcode 4 中出现此错误。我正在阅读一本我认为使用 0.99.5 的书,并且我正在使用 cocos2d 的 1.0.0 框架。

错误:语义问题:从不兼容的类型“double”分配给“CGPoint”(又名“struct 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;
}

【问题讨论】:

    标签: iphone cocos2d-iphone


    【解决方案1】:

    playerVelocity 是一个向量,所以你应该像这样给它赋值:

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

    ccp 宏将使用您指定的两个组件为您构建一个向量。我将 0 作为 y 组件,您可以根据需要随意更改此值。

    【讨论】:

      【解决方案2】:

      所以 playerVelocity 是一个点,但 "playerVelocity.x * dec + acceleration.x * sens" 是一个双精度数。

      你不能给一个点赋值。

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多