In video games, you will see many member variables that have sub-values. For example, the [code]position[/code] we mentioned has two coordinates: [code]x[/code] and [code]y[/code]. It's the same for the [code]scale[/code]: it has [code]x[/code] and [code]y[/code] sub-variables. They respectively control the horizontal and vertical size of the game entity. To access those X and Y sub-components, you add a dot (".") after the variable name. The code below places the entity at [code]200[/code] pixels on the x-axis and [code]250[/code] pixels on the y-axis.
I videospel kommer du att se många medlemsvariabler som har undervärden. Till exempel har medlemsvariablen [code]position[/code] två koordinater: [kod]x[/kod] och [kod]y[/kod]. Samma sak gäller för [code]scale[/code]: den har undervariablerna [code]x[/code] och [code]y[/code]. De styr den horisontella respektive den vertikala storleken på spelentiteten. För att komma åt dessa X- och Y-komponenter lägger du till en punkt (".") efter variabelnamnet. Koden nedan placerar entiteten vid [code]180[/code] pixlar på x-axeln och [code]120[/code] pixlar på y-axeln.
For example, the [code]position[/code] we mentioned has two coordinates: [code]x[/code] and [code]y[/code].
It's the same for the [code]scale[/code]: it has [code]x[/code] and [code]y[/code] sub-variables. They respectively control the horizontal and vertical size of the game entity.
To access those X and Y sub-components, you add a dot (".") after the variable name.
The code below places the entity at [code]200[/code] pixels on the x-axis and [code]250[/code] pixels on the y-axis.
Till exempel har medlemsvariablen [code]position[/code] två koordinater: [kod]x[/kod] och [kod]y[/kod].
Samma sak gäller för [code]scale[/code]: den har undervariablerna [code]x[/code] och [code]y[/code]. De styr den horisontella respektive den vertikala storleken på spelentiteten.
För att komma åt dessa X- och Y-komponenter lägger du till en punkt (".") efter variabelnamnet.
Koden nedan placerar entiteten vid [code]180[/code] pixlar på x-axeln och [code]120[/code] pixlar på y-axeln.