开发者

Float comparison mismatch

I have an extremely weird error that I cannot figure 开发者_如何学Goout.

float distance = Utils.distance(this.spriteStartX, this.spriteStartY, this.getX(), this.getY());

Utils.log("D_Check: "+distance+" >= "+this.spriteDistance);

if(distance >= this.spriteDistance);
{
    Utils.log(distance+" is greater than "+this.spriteDistance);
}

In this code I determine the distance between where my sprite originated and its' current location. (for the sake of simplicity, this is 8.034246f). this.spriteDistance is 7000.0f.

In the debugger I am receiving:

D_Check: 8.034246 >= 7000.0
8.034246 is greater than 7000.0

Obviously something is very wrong with this. Have I missed something incredibly simple?


Remove the semicolon after the if statement.

if (distance >= this.spriteDistance)
{
    Utils.log(distance+" is greater than "+this.spriteDistance);
}


Remove the semi-colon at the end of the if statement.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜