Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Godot;
- using System;
- public class Slot : Control
- {
- private bool isDragged = false;
- // 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 _PhysicsProcess(float delta)
- {
- if (isDragged)
- {
- RectGlobalPosition = GetGlobalMousePosition();
- }
- }
- private void _on_Slot_gui_input(InputEvent @event)
- {
- if (@event is InputEventMouseButton mouseButton)
- {
- if (mouseButton.ButtonIndex == (int)ButtonList.Left)
- {
- if (mouseButton.Pressed)
- {
- isDragged = true;
- }
- else
- {
- isDragged = false;
- }
- }
- else if (mouseButton.ButtonIndex == (int)ButtonList.Right && mouseButton.Pressed)
- {
- GetTree().Root.GetNode<Player>("Node2D/Player").RemoveItem(this);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement