summaryrefslogtreecommitdiffstats
path: root/scene/resources/sprite_frames.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-09-03 11:43:00 +0200
committerRémi Verschelde <rverschelde@gmail.com>2024-09-03 11:43:00 +0200
commit56330801475dd96cc681ba504274b7072d1bf7ce (patch)
tree955d565448b9f25aa50477ad60032a93c5dde397 /scene/resources/sprite_frames.cpp
parent667778cf4de35d5e1f00f59eef804928cf4b639c (diff)
parent57bc1d75746e4e59961b963460024a40bc03ffa8 (diff)
downloadredot-engine-56330801475dd96cc681ba504274b7072d1bf7ce.tar.gz
Merge pull request #93624 from EAinsley/complete#3942
Add duplicate animation for SpriteFrames
Diffstat (limited to 'scene/resources/sprite_frames.cpp')
-rw-r--r--scene/resources/sprite_frames.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/scene/resources/sprite_frames.cpp b/scene/resources/sprite_frames.cpp
index 6e43ea9b17..dac0ceaa78 100644
--- a/scene/resources/sprite_frames.cpp
+++ b/scene/resources/sprite_frames.cpp
@@ -106,6 +106,12 @@ bool SpriteFrames::has_animation(const StringName &p_anim) const {
return animations.has(p_anim);
}
+void SpriteFrames::duplicate_animation(const StringName &p_from, const StringName &p_to) {
+ ERR_FAIL_COND_MSG(!animations.has(p_from), vformat("SpriteFrames doesn't have animation '%s'.", p_from));
+ ERR_FAIL_COND_MSG(animations.has(p_to), vformat("Animation '%s' already exists.", p_to));
+ animations[p_to] = animations[p_from];
+}
+
void SpriteFrames::remove_animation(const StringName &p_anim) {
animations.erase(p_anim);
}
@@ -246,6 +252,7 @@ void SpriteFrames::get_argument_options(const StringName &p_function, int p_idx,
void SpriteFrames::_bind_methods() {
ClassDB::bind_method(D_METHOD("add_animation", "anim"), &SpriteFrames::add_animation);
ClassDB::bind_method(D_METHOD("has_animation", "anim"), &SpriteFrames::has_animation);
+ ClassDB::bind_method(D_METHOD("duplicate_animation", "anim_from", "anim_to"), &SpriteFrames::duplicate_animation);
ClassDB::bind_method(D_METHOD("remove_animation", "anim"), &SpriteFrames::remove_animation);
ClassDB::bind_method(D_METHOD("rename_animation", "anim", "newname"), &SpriteFrames::rename_animation);