Cannot Implicitly Convert Type in XNA

前端 未结 4 1907
夕颜
夕颜 2021-01-24 20:19

i have a bouncing ball, and i tried to make so when it bounces once, the speed gets higher.

In my ball class, i have a float speed;

and i initialize

4条回答
  •  没有蜡笔的小新
    2021-01-24 20:47

    Does the speed needs to be float? If not you could make

    int speed;
    

    Or use a explicit cast

    if (movingUp) { ballRect.Y -= (int)speed; }// No Error
    

提交回复
热议问题