a godot 4 addon · version 1.0 · author: grace re
a NinePatchRect that plays a SpriteFrames atlas, swapping the
texture per frame while keeping the nine-patch slice intact. instead of a fixed texture,
the node shows a looping animation inside a stretchable frame — handy for animated
buttons, panels, and boxes that need to scale without distorting the corners.
1. copy the addon into your project
res://addons/animated_nine_patch/
2. enable it in godot
project settings → plugins → animated ninepatch rect
that adds AnimatedNinePatchRect to the node panel with the addon icon.
var panel = AnimatedNinePatchRect.new()
add_child(panel)
panel.sprite_frames = frames # a SpriteFrames with your atlas
panel.animation = "pulse" # pick an animation
panel.play("pulse")
panel.animation_finished.connect(func(name):
print("done: ", name))
exported properties make it work in the editor too — set sprite_frames,
pick animation, tick autoplay, done.
| exported | type | notes |
|---|---|---|
sprite_frames | SpriteFrames | atlas with the frames |
animation | StringName | active animation |
autoplay | StringName | animation to start on ready |
frame | int | current frame |
playing | bool | play / pause |
speed_scale | float | playback speed multiplier |
| methods | ||
play(name) | start an animation from frame 0 | |
stop() | stop and reset to frame 0 | |
pause() | pause on the current frame | |
is_playing() | is it running? | |
get_animation_list() | names of all animations | |
| signals | ||
animation_finished(name) | fires when a non-looping animation ends | |