mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-04 14:11:02 +03:00
Update first_2d_game C# variables capitalization (#4723)
This commit is contained in:
@@ -37,13 +37,13 @@ Start by declaring the member variables this object will need:
|
||||
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
|
||||
public class Player : Area2D
|
||||
{
|
||||
[Export]
|
||||
public int speed = 400; // How fast the player will move (pixels/sec).
|
||||
public int Speed = 400; // How fast the player will move (pixels/sec).
|
||||
|
||||
public Vector2 screenSize; // Size of the game window.
|
||||
public Vector2 ScreenSize; // Size of the game window.
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ a good time to find the size of the game window:
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
screenSize = GetViewportRect().Size;
|
||||
ScreenSize = GetViewportRect().Size;
|
||||
}
|
||||
|
||||
Now we can use the ``_process()`` function to define what the player will do.
|
||||
@@ -147,7 +147,7 @@ which returns ``true`` if it's pressed or ``false`` if it isn't.
|
||||
|
||||
if (velocity.Length() > 0)
|
||||
{
|
||||
velocity = velocity.Normalized() * speed;
|
||||
velocity = velocity.Normalized() * Speed;
|
||||
animatedSprite.Play();
|
||||
}
|
||||
else
|
||||
@@ -199,8 +199,8 @@ the ``_process`` function (make sure it's not indented under the `else`):
|
||||
|
||||
Position += velocity * delta;
|
||||
Position = new Vector2(
|
||||
x: Mathf.Clamp(Position.x, 0, screenSize.x),
|
||||
y: Mathf.Clamp(Position.y, 0, screenSize.y)
|
||||
x: Mathf.Clamp(Position.x, 0, ScreenSize.x),
|
||||
y: Mathf.Clamp(Position.y, 0, ScreenSize.y)
|
||||
);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user