diff --git a/creaturegodot/creaturegodot.cpp b/creaturegodot/creaturegodot.cpp index b09e528..19eebb2 100644 --- a/creaturegodot/creaturegodot.cpp +++ b/creaturegodot/creaturegodot.cpp @@ -90,7 +90,7 @@ static bool add_loaded_animation(CreatureModule::CreatureManager * creature_mana return false; } -void +bool CreatureGodot::load_json(const String& filename_in) { auto global_path = Globals::get_singleton()->globalize_path(filename_in); @@ -101,7 +101,7 @@ CreatureGodot::load_json(const String& filename_in) if(!can_load) { std::cout<<"CreatureGodot::load_json() - ERRROR! Could not load file: "<SetActiveAnimationName(first_animation_name); anim_name = String(first_animation_name.c_str()); + + return true; } bool CreatureGodot::blend_to_animation(String animation_name, float blend_delta) @@ -315,9 +317,13 @@ Color CreatureGodot::get_color() const{ void CreatureGodot::set_asset_filename(const String& filename_in) { - asset_filename = filename_in; - load_json(filename_in); - update_animation(0.1f); + auto retval = load_json(filename_in); + + if(retval) + { + asset_filename = filename_in; + update_animation(0.1f); + } } String CreatureGodot::get_asset_filename() const diff --git a/creaturegodot/creaturegodot.h b/creaturegodot/creaturegodot.h index 7daed49..dded11e 100644 --- a/creaturegodot/creaturegodot.h +++ b/creaturegodot/creaturegodot.h @@ -36,7 +36,7 @@ class CreatureGodot : public Node2D { static void _bind_methods(); public: - void load_json(const String& filename_in); + bool load_json(const String& filename_in); void update_animation(float delta);