diff options
author | Jared Adams <jaxad0127@gmail.com> | 2010-05-20 01:35:17 -0600 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2010-05-20 12:25:37 -0600 |
commit | 487a86fe7dc9904f445d91667095f641f72f7c81 (patch) | |
tree | 57191d175f7b2fe771f6b2da225bc2d9cb5ff1d9 /src/being.cpp | |
parent | 36832f3a5378f739da7040f0711b7101dbc2af02 (diff) | |
download | mana-487a86fe7dc9904f445d91667095f641f72f7c81.tar.gz mana-487a86fe7dc9904f445d91667095f641f72f7c81.tar.bz2 mana-487a86fe7dc9904f445d91667095f641f72f7c81.tar.xz mana-487a86fe7dc9904f445d91667095f641f72f7c81.zip |
Buffer layered sprites under SDL
This improves framerate and allows transparent overlay for complex
sprites. Two copies of the buffer are kept, one at full opacity,
one with variable opactiy, to reduce calls to setAlpha.
Reviewed-by: Bertram
Diffstat (limited to 'src/being.cpp')
-rw-r--r-- | src/being.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/being.cpp b/src/being.cpp index a2180c84..24f2e2e1 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -1063,7 +1063,7 @@ void Being::setSprite(unsigned int slot, int id, const std::string &color, assert(slot < Net::getCharHandler()->maxSprite()); if (slot >= size()) - resize(slot + 1, NULL); + ensureSize(slot + 1); if (slot >= mSpriteIDs.size()) mSpriteIDs.resize(slot + 1, 0); @@ -1074,8 +1074,7 @@ void Being::setSprite(unsigned int slot, int id, const std::string &color, // id = 0 means unequip if (id == 0) { - delete at(slot); - at(slot) = NULL; + removeSprite(slot); if (isWeapon) mEquippedWeapon = NULL; @@ -1097,10 +1096,7 @@ void Being::setSprite(unsigned int slot, int id, const std::string &color, if (equipmentSprite) equipmentSprite->setDirection(getSpriteDirection()); - if (at(slot)) - delete at(slot); - - at(slot) = equipmentSprite; + CompoundSprite::setSprite(slot, equipmentSprite); if (isWeapon) mEquippedWeapon = &ItemDB::get(id); @@ -1124,7 +1120,7 @@ void Being::setSpriteColor(unsigned int slot, const std::string &color) int Being::getNumberOfLayers() const { - return size(); + return CompoundSprite::getNumberOfLayers(); } void Being::load() |