クラスから別のクラスにゲッターとセッターを呼び出すにはどうすればよいですか? Ball.cs から StartGame.cs という名前の別のクラスを呼び出す必要があります。StartGame.cs のタイマーに入れる必要があります。たとえば、クラス Ball.
public class Ball
{
public int speedX { get; private set; }
public int speedY { get; private set; }
public int positionX { get; private set; }
public int positionY { get; private set; }
public Ball(int speedX, int speedY, int positionX, int positionY)
{
this.speedX = speedX;
this.speedY = speedY;
this.positionX = positionX;
this.positionY = positionY;
}
public int setSpeedX(int newSpeedX)
{
speedX = newSpeedX;
return newSpeedX;
}
public int setSpeedY(int newSpeedY)
{
speedY = newSpeedY;
return newSpeedY;
}
public int setPositionX(int newPositionX)
{
positionX = newPositionX;
return newPositionX;
}
public int setPositionY(int newPositionY)
{
positionY = newPositionY;
return newPositionY;
}
}
ありがとうございました。