Skip to content

Commit

Permalink
fix: fix sprite reset
Browse files Browse the repository at this point in the history
  • Loading branch information
Milerius committed Oct 29, 2019
1 parent e19cc99 commit 13ff5ef
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion modules/graphics/antara/gaming/graphics/component.sprite.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#pragma once

#include <string> //! std::string
#include "antara/gaming/transform/component.properties.hpp"
#include "antara/gaming/transform/component.position.hpp"
#include "antara/gaming/core/safe.refl.hpp"
Expand All @@ -31,7 +32,7 @@ namespace antara::gaming::graphics

struct sprite
{
const char *appearance; //! texture id
std::string appearance; //! texture id
bool native_size{true}; //! take the whole size by default
rect texture_rec{}; //! Set the sub-rectangle of the texture that the sprite will display if native_size is false
};
Expand Down
4 changes: 2 additions & 2 deletions modules/sfml/antara/gaming/sfml/graphic.system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,8 @@ namespace antara::gaming::sfml
graphic_system::on_sprite_construct(entt::entity entity, entt::registry &registry, graphics::sprite &spr) noexcept
{
auto &resources_system = this->entity_registry_.ctx<sfml::resources_system>();
auto handle = resources_system.load_texture(spr.appearance);
sf::Sprite &native_sprite = registry.assign<sfml::sprite>(entity, sf::Sprite(handle.get())).drawable;
auto handle = resources_system.load_texture(spr.appearance.c_str());
sf::Sprite &native_sprite = registry.assign_or_replace<sfml::sprite>(entity, sf::Sprite(handle.get())).drawable;

if (not spr.native_size) {
auto[left, top] = spr.texture_rec.pos;
Expand Down

0 comments on commit 13ff5ef

Please sign in to comment.