mirror of
https://github.com/stan220/godot-docs.git
synced 2026-09-08 19:29:06 +00:00
Merge pull request #8302 from paulloz/C#-capitalization-issues
C#: Fix some forgotten lowercase x/y/z
This commit is contained in:
@@ -459,7 +459,7 @@ Here's the *Player* script.
|
||||
// Jumping.
|
||||
if (IsOnFloor() && Input.IsActionJustPressed("jump"))
|
||||
{
|
||||
_targetVelocity.y += JumpImpulse;
|
||||
_targetVelocity.Y += JumpImpulse;
|
||||
}
|
||||
|
||||
// Iterate through all collisions that occurred this frame.
|
||||
|
||||
@@ -158,13 +158,17 @@ It is possible to rotate a transform, either by multiplying its basis by another
|
||||
|
||||
.. code-tab:: csharp
|
||||
|
||||
Transform3D transform = Transform;
|
||||
Vector3 axis = new Vector3(1, 0, 0); // Or Vector3.Right
|
||||
float rotationAmount = 0.1f;
|
||||
|
||||
// Rotate the transform around the X axis by 0.1 radians.
|
||||
transform.Basis = new Basis(axis, rotationAmount) * transform.Basis;
|
||||
// shortened
|
||||
transform.Basis = transform.Basis.Rotated(axis, rotationAmount);
|
||||
|
||||
Transform = transform;
|
||||
|
||||
A method in Node3D simplifies this:
|
||||
|
||||
.. tabs::
|
||||
|
||||
@@ -85,8 +85,8 @@ To do this in code, we multiply each of the vectors:
|
||||
|
||||
Transform2D t = Transform2D.Identity;
|
||||
// Scale
|
||||
t.x *= 2;
|
||||
t.y *= 2;
|
||||
t.X *= 2;
|
||||
t.Y *= 2;
|
||||
Transform = t; // Change the node's transform to what we calculated.
|
||||
|
||||
If we wanted to return it to its original scale, we can multiply
|
||||
@@ -324,7 +324,7 @@ As an example, let's set Y to (1, 1):
|
||||
|
||||
Transform2D t = Transform2D.Identity;
|
||||
// Shear by setting Y to (1, 1)
|
||||
t.y = Vector2.One;
|
||||
t.Y = Vector2.One;
|
||||
Transform = t; // Change the node's transform to what we calculated.
|
||||
|
||||
.. note:: You can't set the raw values of a Transform2D in the editor,
|
||||
|
||||
@@ -189,9 +189,9 @@ degrees to either side:
|
||||
// Calculate vector from `a` to `b`.
|
||||
var dvec = pointA.DirectionTo(pointB);
|
||||
// Rotate 90 degrees.
|
||||
var normal = new Vector2(dvec.y, -dvec.x);
|
||||
var normal = new Vector2(dvec.Y, -dvec.X);
|
||||
// Alternatively (depending the desired side of the normal):
|
||||
// var normal = new Vector2(-dvec.y, dvec.x);
|
||||
// var normal = new Vector2(-dvec.Y, dvec.X);
|
||||
|
||||
The rest is the same as the previous example. Either point_a or
|
||||
point_b will work, as they are in the same plane:
|
||||
|
||||
@@ -93,10 +93,10 @@ a TextureRect can be centered in its parent:
|
||||
|
||||
var textureSize = rect.Texture.GetSize();
|
||||
|
||||
rect.OffsetLeft = -textureSize.x / 2;
|
||||
rect.OffsetRight = textureSize.x / 2;
|
||||
rect.OffsetTop = -textureSize.y / 2;
|
||||
rect.OffsetBottom = textureSize.y / 2;
|
||||
rect.OffsetLeft = -textureSize.X / 2;
|
||||
rect.OffsetRight = textureSize.X / 2;
|
||||
rect.OffsetTop = -textureSize.Y / 2;
|
||||
rect.OffsetBottom = textureSize.Y / 2;
|
||||
AddChild(rect);
|
||||
|
||||
Setting each anchor to 0.5 moves the reference point for the margins to
|
||||
|
||||
Reference in New Issue
Block a user