多分私は夢中ですが、私はXNA Game Developmentクラスで学んだロジックをAndroid/Javaゲームプログラミングに取り入れたいと思っています。たとえば、Vector2ではなくPointを使用してプログラムのグラフィックスの位置を操作し、Androidデバイスのdpiと向きに基づいてグラフィックサイズを調整します。簡単な数学演算子での奇妙なJavaエラー
GUIをレイアウトして、どのフォルダ(hdpi、ldpi、またはmdpi)からグラフィックを取り出すべきかを判断するときに、グラフィックの中心を見つけることは素晴らしい資産と考えました。残念ながら、Eclipseにはプラス記号の問題があるようです。私は、単純な数学的操作を実行しようとしていますので、これは興味深いです:
演算子+は、引数の型(S)android.graphics.Point、android.graphics.Point
//Java code was both copied & pasted as well as written to make sure Visual Studio
public Point Center()
{
return new Point(_frameWidth/2, _frameHeight/2)+_location;
}
//Original XNA code
//Determines the coordinates of a sprite's center
public Vector2 Center
{
get
{
return _location + new Vector2(_frameWidth/2, _frameHeight/2);
}
}
ために定義されていません
問題解決 - 2つの点のX値とY値を別々のステートメントに追加しました。 C#からJavaに移行するのは面白い経験ですが、私はその挑戦の準備ができています。ありがとう! \t公共ポイントセンター() \t {\t \t INT X = _frameWidth/2 + _location.x。 \t \t int y = _frameHeight/2 + _location.y; \t \t return新しいポイント(x、y); \t} – Shortstuff81000