From 76053d11d679a9580a08d10b2f623d81c41fafa7 Mon Sep 17 00:00:00 2001 From: Juan Pablo Orsay Date: Wed, 20 Mar 2013 21:10:40 -0300 Subject: [PATCH] correctted loadFromMemory --- src/cricketsfml/include/cricketsfml/graphics/Sprite.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cricketsfml/include/cricketsfml/graphics/Sprite.h b/src/cricketsfml/include/cricketsfml/graphics/Sprite.h index 6d6e85c..004b211 100644 --- a/src/cricketsfml/include/cricketsfml/graphics/Sprite.h +++ b/src/cricketsfml/include/cricketsfml/graphics/Sprite.h @@ -45,17 +45,19 @@ friend class window::SFMLWindow; FloatPoint getScale() const; inline static Sprite* loadFromMemory(const char* data, uint64_t size) { - sf::Texture t; if (data == 0) { std::cout << "failed to load sprite from memory: empty data" << std::endl; return 0; } - if (!t.loadFromMemory(data, size)) { + sf::Texture* t = new sf::Texture(); + if (!t->loadFromMemory(data, size)) { std::cout << "failed to load sprite from memory: t.loadFromMemory failed" << std::endl; return 0; } Sprite* s = new Sprite(); - s->setSprite(new sf::Sprite(t)); + sf::Sprite* sf = new sf::Sprite(); + sf->setTexture(*t); + s->setSprite(sf); return s; } };