简体   繁体   中英

All my syntax is correct, why isn't my sprite spinning?

I am trying to learn Godot, so I am following a tutorial. However, when I attempt to run the code, it does not work, even though all the syntax is the same as the tutorial. Could this be a technical issue? (I am using the internal Godot editor for c#)

My code is as follows:

using Godot;

public class Sprite : Godot.Sprite
{
    private int Speed = 400;
    private float AngularSpeed = Mathf.Pi;

    public override void _Process(float delta)
    {
        Rotation += AngularSpeed * delta;
        var velocity = Vector2.Up.Rotated(Rotation) * Speed;

        Position += velocity * delta;

    }
}

Your code works fine.

The only solution i could find is to try to paste it all into something like notepad and gedit(open res:// in file manager of choice).

Make sure the sprite has the script attached and that it is all in a Node2D root scene as seen in the attached example. Make sure that the sprite Node has that scroll icon to the right. Otherwise try reinstalling and have a look for any compile errors and warnings:)

Example

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM