Check out our latest project ✨ OpenChapter.io: free ebooks the way its meant to be 📖

DraggableSprite2D

An asset by birdt_
The page banner background of a mountain and forest
DraggableSprite2D hero image

Quick Information

0 ratings
DraggableSprite2D icon image
birdt_
DraggableSprite2D

A simple Sprite2D which can be dragged with the mouse by clicking and holding with a mouse button.

Supported Engine Version
4.2
Version String
1.2
License Version
AGPLv3
Support Level
community
Modified Date
1 year ago
Git URL
Issue URL

DraggableSprite2D

A simple Sprite2D which can be dragged with the mouse by clicking and holding with a mouse button.

Usage

To use, just add a texture and ignore the warning in the editor. A collision shape is automatically generated on _ready.

You can also use a custom collision shape by adding it as a child.

All code is commented to explain the export values, but for reference:

  • input_method: The mouse button to listen for to grab the sprite.
  • texture: The Sprite2D texture. This updates live in the editor, as long as you swap editor tabs after changing it.
  • return_to_origin: Whether the sprite should return to it's starting point once released.
  • grabbable: Whether the sprite can be grabbed.
  • origin: The position to return to when released, if return_to_origin is true. Note that this is set to the sprite's starting position on _ready, so it should only be updated at runtime and not set in the editor.

A simple Sprite2D which can be dragged with the mouse by clicking and holding with a mouse button.

Reviews

0 ratings

Your Rating

Headline must be at least 3 characters but not more than 50
Review must be at least 5 characters but not more than 500
Please sign in to add a review

Quick Information

0 ratings
DraggableSprite2D icon image
birdt_
DraggableSprite2D

A simple Sprite2D which can be dragged with the mouse by clicking and holding with a mouse button.

Supported Engine Version
4.2
Version String
1.2
License Version
AGPLv3
Support Level
community
Modified Date
1 year ago
Git URL
Issue URL

Open Source

Released under the AGPLv3 license

Plug and Play

Browse assets directly from Godot

Community Driven

Created by developers for developers