且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

获取查看在其它类变量

更新时间:2023-11-30 16:22:58

声明你要访问为public,或者创建get方法的变量

Declare the variables you want to access as public, or create get methods.

有关公共变量,你会怎么做:

For public variables you would do:

public Vector2 Position;

和访问它,你会叫:

Ball ball;
ball.Position

有关get方法实现:

public Vector2 getPosition()
{
    return Position;
}

和你会调用该方法得到的位置。

And you would call that method to get the position.