nine patch icon animated ninepatch rect

a godot 4 addon · version 1.0 · author: grace re

what it is

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.

install

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.

usage

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.

api

exportedtypenotes
sprite_framesSpriteFramesatlas with the frames
animationStringNameactive animation
autoplayStringNameanimation to start on ready
frameintcurrent frame
playingboolplay / pause
speed_scalefloatplayback 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