Skip to content

Commit

Permalink
Background animations via scene file
Browse files Browse the repository at this point in the history
  • Loading branch information
pinguin999 committed Oct 8, 2024
1 parent 40ec281 commit 6afe97b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,12 @@ Scene::Scene(const std::string &fileName, const std::shared_ptr<Game> &game) : f
}
else if (json["background"].IsDefined() && !json["background"].IsNull())
{
auto const animation = (*game->lua_state)["config"]["background_default_animation"];
std::string animation = (*game->lua_state)["config"]["background_default_animation"];
auto const spine = json["background"]["spine"].as<std::string>();
if(json["background"]["animation"].IsDefined() && !json["background"]["animation"].IsNull())
{
animation = json["background"]["animation"].as<std::string>();
}
if (!(*game->lua_state)["scenes"][scene]["background"].valid())
{
(*game->lua_state)["scenes"][scene]["background"] = game->lua_state->create_table_with(
Expand All @@ -156,6 +160,7 @@ Scene::Scene(const std::string &fileName, const std::shared_ptr<Game> &game) : f
}
background = std::make_shared<Background>(game, spine);
background->setPosition(jngl::Vec2(0, 0));
background->playAnimation(0, animation, true, (*game->lua_state)["pass"]);
background->layer = 0;
if (json["background"]["skin"])
{
Expand Down

0 comments on commit 6afe97b

Please sign in to comment.