반응형

프로젝트 세팅 창을 열려고 하면 작동을 멈추는 버그가 발생할 수 있다.

 

Project Settings... 를 클릭하면 그 다음부터 아무 동작도 하지 않는다.

 

프로젝트 폴더 - .godot 폴더를 삭제한다.

 

다른 문제가 발생할지 모르니 프로젝트 폴더는 미리 백업해 둔다.

작업중인 프로젝트 폴더의 .godot 폴더를 삭제하고 다시 실행한다. 그러면 Godot 엔진이 .godot 폴더를 다시 빌드하고 문제가 해결된다.

 

반응형
Posted by J-sean
:
반응형

사용자 시그널을 받아 보자.

 

Node2D를 생성하고 스크립트(Receiver.cs)를 붙여준다.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using Godot;
 
public partial class Receiver : Node2D
{
    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        Sender sender = GetNode<Sender>("Sprite2D");
        // "Sprite2D" is the name of the Node in the scene.
        sender.Accept += OnAccept;
    }
 
    private void OnAccept()
    {
        GD.Print("Accept!!");
    }
 
    // Called every frame. 'delta' is the elapsed time since the previous frame.
    public override void _Process(double delta)
    {
    }
}
 

 

 

Accept 시그널(엔터키)을 받는 스크립트를 작성한다.

 

Sprite2D를 생성하고 스크립트(Sender.cs)를 붙여준다.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
using Godot;
 
public partial class Sender : Sprite2D
{
    [Signal]
    public delegate void AcceptEventHandler();    
 
    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
    }
 
    // Called every frame. 'delta' is the elapsed time since the previous frame.
    public override void _Process(double delta)
    {
        if (Input.IsActionJustPressed("ui_accept"))
        {
            EmitSignal(SignalName.Accept);
        }
    }
}
 

 

 

Accept 시그널(엔터키)을 보내는 스크립트를 작성한다.

시그널 delegate 이름은 [시그널 이름 + EventHandler] 형식으로 작성한다. 위 코드의 경우 시그널 이름이 Accept이고 delegate 이름은 AcceptEventHandler이다.

 

 

씬을 저장하고 게임을 실행하면 엔터키가 눌릴 때마다 Output 창에 Accept!! 메세지가 출력된다.

 

※ 참고

Using signals

C# signals

 

반응형
Posted by J-sean
:
반응형

타이머가 보내는 시그널을 받아보자.

 

Sprite2D 노드를 생성하고 Texture를 연결한다.

 

Sprite2D 노드의 자식 노드로 Timer 노드를 생성하고 Autostart 속성을 활성화 한다.

 

Sprite2D 노드에 스크립트를 생성한다.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
using Godot;
 
public partial class player : Sprite2D
{
    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        Timer timer = GetNode<Timer>("Timer");
        timer.Timeout += OnTimeout;
    }
 
    private void OnTimeout()
    {
        GD.Print("Timeout!!");
    }
 
    // Called every frame. 'delta' is the elapsed time since the previous frame.
    public override void _Process(double delta)
    {
    }
}
 

 

 

Timeout 시그널을 받는 스크립트를 작성한다.

 

 

Sprite2D 노드에 스크립트(player.cs)가 생성되었다.

 

씬을 저장하고 게임을 실행하면 Output 창에 Timeout!! 메세지가 반복해서 출력된다.

 

※ 참고

Using signals

C# signals

 

반응형
Posted by J-sean
: