Optimitzat el tema de comparacions i asignacions de strings buits. Mes que optimitzat, ara està mes mono
This commit is contained in:
@@ -37,7 +37,7 @@ AnimatedFile loadAnimationFromFile(std::shared_ptr<Texture> texture, std::string
|
||||
buffer.counter = 0;
|
||||
buffer.current_frame = 0;
|
||||
buffer.completed = false;
|
||||
buffer.name = "";
|
||||
buffer.name.clear();
|
||||
buffer.speed = 5;
|
||||
buffer.loop = 0;
|
||||
buffer.frames.clear();
|
||||
@@ -159,18 +159,15 @@ AnimatedFile loadAnimationFromFile(std::shared_ptr<Texture> texture, std::string
|
||||
|
||||
// Constructor
|
||||
AnimatedSprite::AnimatedSprite(std::shared_ptr<Texture> texture, const std::string &file, std::vector<std::string> *buffer)
|
||||
: MovingSprite(texture)
|
||||
: MovingSprite(texture),
|
||||
current_animation_(0)
|
||||
{
|
||||
// Carga las animaciones
|
||||
if (file != "")
|
||||
if (!file.empty())
|
||||
{
|
||||
AnimatedFile as = loadAnimationFromFile(texture, file);
|
||||
|
||||
// Copia los datos de las animaciones
|
||||
/*for (auto animation : as.animations)
|
||||
{
|
||||
animations_.push_back(animation);
|
||||
}*/
|
||||
std::copy(as.animations.begin(), as.animations.end(), std::back_inserter(animations_));
|
||||
}
|
||||
|
||||
@@ -178,18 +175,13 @@ AnimatedSprite::AnimatedSprite(std::shared_ptr<Texture> texture, const std::stri
|
||||
{
|
||||
loadFromVector(buffer);
|
||||
}
|
||||
|
||||
// Inicializa variables
|
||||
current_animation_ = 0;
|
||||
}
|
||||
|
||||
// Constructor
|
||||
AnimatedSprite::AnimatedSprite(const AnimatedFile *animation)
|
||||
: MovingSprite(animation->texture)
|
||||
: MovingSprite(animation->texture),
|
||||
current_animation_(0)
|
||||
{
|
||||
// Inicializa variables
|
||||
current_animation_ = 0;
|
||||
|
||||
// Copia los datos de las animaciones
|
||||
std::copy(animation->animations.begin(), animation->animations.end(), std::back_inserter(animations_));
|
||||
}
|
||||
@@ -366,7 +358,7 @@ bool AnimatedSprite::loadFromVector(std::vector<std::string> *source)
|
||||
buffer.counter = 0;
|
||||
buffer.current_frame = 0;
|
||||
buffer.completed = false;
|
||||
buffer.name = "";
|
||||
buffer.name.clear();
|
||||
buffer.speed = 5;
|
||||
buffer.loop = 0;
|
||||
buffer.frames.clear();
|
||||
|
||||
Reference in New Issue
Block a user