C#位置大于.... [英] C# Location Greater then...................
问题描述
这是我的代码
This is my code
if (Death.Location == new Point(Death.Location.X <= 30, Death.Location.Y))
{
Death.Location = new Point(Death.Location.X - movement, Death.Location.Y);
}
这些是我的错误
<pre lang="vb">Error 1 The best overloaded method match for ''System.Drawing.Point.Point(int, int)'' has some invalid arguments C:\Users\Kyle\documents\visual studio 2010\Projects\Game 1\Game 1\Form2.cs 156 39 Game 1</pre>
<pre lang="vb">Error 2 Argument 1: cannot convert from ''bool'' to ''int'' C:\Users\Kyle\documents\visual studio 2010\Projects\Game 1\Game 1\Form2.cs 156 49 Game 1</pre>
these are my errors
<pre lang="vb">Error 1 The best overloaded method match for ''System.Drawing.Point.Point(int, int)'' has some invalid arguments C:\Users\Kyle\documents\visual studio 2010\Projects\Game 1\Game 1\Form2.cs 156 39 Game 1</pre>
<pre lang="vb">Error 2 Argument 1: cannot convert from ''bool'' to ''int'' C:\Users\Kyle\documents\visual studio 2010\Projects\Game 1\Game 1\Form2.cs 156 49 Game 1</pre>
推荐答案
if(Death.Location.X <=30)
{
//your code goes here
}
这是因为Death.Location.X <= 30
是布尔值,但您需要整数.
似乎您不了解自己想要什么.您将Death.Location
与Death.Location
进行比较,然后分配Death.Location
...
—SA
This is becauseDeath.Location.X <= 30
is boolean, but you need integer.
It does not seem you understand what do you want. You compareDeath.Location
withDeath.Location
and then assignDeath.Location
…
—SA
这篇关于C#位置大于....的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!