HoverShake2D's icon

HoverShake2D 1.0 Scripts 3.2 Community

Submitted by user SlushyGames; CC0; 2021-02-02

This is a simple script/class that you can use on a node that inherits Node2D (e.g. Sprite). This script is an easy way to add a nice hover or shake effect to your nodes without the need of any additional child nodes.

var hover_shake = HoverShake2D.new()

In your node's _ready() function, initialize the behavior using your node as its target:

func _ready():
hover_shake.init(self)

Then, during your node's _update() function, simply pass the delta into the behavior:

func _process(delta):
hover_shake.update(delta)


Now your node is hovering! Or shaking, if you use extra options:

hover_shake.init(self, "random", 0, 2, 200) // fast shake

- Second parameter is starting direction, possible values are "random", "up", "down", "left", "right" (default "random")
- Third parameter is vertical distance of the hover in pixels (0 for no hover, default 15)
- Fourth parameter is horizontal distance of the shake in pixels (0 for no shake, default 0)
- Fifth parameter is speed of the hover/shake (default 10)

That's it! Super easy hover, super simple shake. Enjoy!


View files Download Submit an issue Recent Edits