mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-04 14:11:02 +03:00
Update some C# examples for 4.0 (#6693)
* Update some C# examples - Rename members that have been renamed in Godot's C# API for 4.0. - Change `delta` parameter type to `double`. - Ensure parameters match base declaration. - Other minor code fixes. --------- Co-authored-by: Paul Joannon <437025+paulloz@users.noreply.github.com>
This commit is contained in:
@@ -104,7 +104,9 @@ way:
|
||||
.. code-tab:: csharp
|
||||
|
||||
var localPos = new Vector2(10,20); // local to Control/Node2D
|
||||
var ie = new InputEventMouseButton();
|
||||
ie.ButtonIndex = (int)ButtonList.Left;
|
||||
ie.Position = (GetViewportTransform() * GetGlobalTransform()).Xform(localPos);
|
||||
var ie = new InputEventMouseButton()
|
||||
{
|
||||
ButtonIndex = MouseButton.Left,
|
||||
Position = GetViewportTransform() * (GetGlobalTransform() * localPos),
|
||||
};
|
||||
GetTree().InputEvent(ie);
|
||||
|
||||
@@ -84,7 +84,7 @@ redrawn if modified:
|
||||
|
||||
using Godot;
|
||||
|
||||
public partial class CustomNode2D : Node2D
|
||||
public partial class MyNode2D : Node2D
|
||||
{
|
||||
private Texture _texture;
|
||||
public Texture Texture
|
||||
@@ -133,7 +133,7 @@ call ``queue_redraw()`` from the ``_process()`` callback, like this:
|
||||
// Your draw commands here
|
||||
}
|
||||
|
||||
public override void _Process(float delta)
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
QueueRedraw();
|
||||
}
|
||||
@@ -387,7 +387,7 @@ using ``get_node()``.
|
||||
|
||||
using Godot;
|
||||
|
||||
public partial class CustomNode2D : Node2D
|
||||
public partial class MyNode2D : Node2D
|
||||
{
|
||||
private float _rotationAngle = 50;
|
||||
private float _angleFrom = 75;
|
||||
@@ -421,7 +421,7 @@ calls ``_draw()``. This way, you can control when you want to refresh the frame.
|
||||
|
||||
.. code-tab:: csharp
|
||||
|
||||
public override void _Process(float delta)
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
_angleFrom += _rotationAngle;
|
||||
_angleTo += _rotationAngle;
|
||||
@@ -490,10 +490,10 @@ smaller value, which directly depends on the rendering speed.
|
||||
|
||||
.. code-tab:: csharp
|
||||
|
||||
public override void _Process(float delta)
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
_angleFrom += _rotationAngle * delta;
|
||||
_angleTo += _rotationAngle * delta;
|
||||
_angleFrom += _rotationAngle * (float)delta;
|
||||
_angleTo += _rotationAngle * (float)delta;
|
||||
|
||||
// We only wrap angles when both of them are bigger than 360.
|
||||
if (_angleFrom > 360 && _angleTo > 360)
|
||||
|
||||
Reference in New Issue
Block a user