本文整理汇总了C++中SpriteSheet::addAnimation方法的典型用法代码示例。如果您正苦于以下问题:C++ SpriteSheet::addAnimation方法的具体用法?C++ SpriteSheet::addAnimation怎么用?C++ SpriteSheet::addAnimation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpriteSheet
的用法示例。
在下文中一共展示了SpriteSheet::addAnimation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load
// TODO: find a cleaner way that this massive mess ?
SpriteSheet* SpriteSheetManager::load(const std::string& textureName)
{
sf::Texture* t = new sf::Texture();
if (!t->loadFromFile(textureName))
{
// BAD!
}
SpriteSheet* s = new SpriteSheet(*t);
if (textureName == "Castle2.png")
{
}
else if (textureName == "wood_tileset_3.png")
{
sf::Sprite* sprite;
sprite = new sf::Sprite(*t, sf::IntRect(0,0,32,32)); // only grass
tiles[TileGame::Grass][TileGame::Grass][TileGame::Grass][TileGame::Grass] = sprite;
sprite = new sf::Sprite(*t, sf::IntRect(64,0,32,32));// grass top left
tiles[TileGame::Grass][TileGame::Grass][TileGame::Earth][TileGame::Grass] = sprite;
sprite = new sf::Sprite(*t, sf::IntRect(64,32,32,32)); // horizontal separation (grass left)
tiles[TileGame::Grass][TileGame::Grass][TileGame::Earth][TileGame::Earth] = sprite;
sprite = new sf::Sprite(*t, sf::IntRect(64,64,32,32)); // grass bottom left
tiles[TileGame::Grass][TileGame::Grass][TileGame::Grass][TileGame::Earth] = sprite;
sprite = new sf::Sprite(*t, sf::IntRect(96,0,32,32)); // vertical separation (grass top)
tiles[TileGame::Grass][TileGame::Earth][TileGame::Earth][TileGame::Grass] = sprite;
sprite = new sf::Sprite(*t, sf::IntRect(96,32,32,32));// only earth
tiles[TileGame::Earth][TileGame::Earth][TileGame::Earth][TileGame::Earth] = sprite;
sprite = new sf::Sprite(*t, sf::IntRect(96,64,32,32));// vertical separation (grass bottom)
tiles[TileGame::Earth][TileGame::Grass][TileGame::Grass][TileGame::Earth] = sprite;
sprite = new sf::Sprite(*t, sf::IntRect(128,0,32,32));// grass right top
tiles[TileGame::Grass][TileGame::Earth][TileGame::Grass][TileGame::Grass] = sprite;
sprite = new sf::Sprite(*t, sf::IntRect(128,32,32,32));// horizontal separation (grass right)
tiles[TileGame::Earth][TileGame::Earth][TileGame::Grass][TileGame::Grass] = sprite;
sprite = new sf::Sprite(*t, sf::IntRect(128,64,32,32)); // grass bottom right
tiles[TileGame::Earth][TileGame::Grass][TileGame::Grass][TileGame::Grass] = sprite;
sprite = new sf::Sprite(*t, sf::IntRect(256,192,32,32)); // grass bottom left, top right
tiles[TileGame::Earth][TileGame::Grass][TileGame::Earth][TileGame::Grass] = sprite;
sprite = new sf::Sprite(*t, sf::IntRect(160,224,32,32)); // grass top left, bottom right
tiles[TileGame::Grass][TileGame::Earth][TileGame::Grass][TileGame::Earth] = sprite;
sprite = new sf::Sprite(*t, sf::IntRect(192,224,32,32)); // minimum grass bottom right
tiles[TileGame::Earth][TileGame::Earth][TileGame::Grass][TileGame::Earth] = sprite;
sprite = new sf::Sprite(*t, sf::IntRect(224,224,32,32)); // minimum grass bottom left
tiles[TileGame::Earth][TileGame::Grass][TileGame::Earth][TileGame::Earth] = sprite;
sprite = new sf::Sprite(*t, sf::IntRect(192,256,32,32)); // minimum grass top right
tiles[TileGame::Earth][TileGame::Earth][TileGame::Earth][TileGame::Grass] = sprite;
sprite = new sf::Sprite(*t, sf::IntRect(224,256,32,32)); // minimum grass top left
tiles[TileGame::Grass][TileGame::Earth][TileGame::Earth][TileGame::Earth] = sprite;
}
else if (textureName == "BODY_male.png")
{
Animation* anim = new Animation();
anim->setSpriteSheet(*t);
anim->addFrame(sf::IntRect(0,0,64,64));
s->addAnimation("idleUp",anim);
anim = new Animation();
anim->setSpriteSheet(*t);
anim->addFrame(sf::IntRect(0,64,64,64));
s->addAnimation("idleLeft",anim);
anim = new Animation();
anim->setSpriteSheet(*t);
anim->addFrame(sf::IntRect(0,128,64,64));
s->addAnimation("idleDown",anim);
anim = new Animation();
anim->setSpriteSheet(*t);
anim->addFrame(sf::IntRect(0,192,64,64));
s->addAnimation("idleRight",anim);
anim = new Animation();
anim->setSpriteSheet(*t);
for (int i = 1; i < 8; ++i)
anim->addFrame(sf::IntRect(i * 64,0,64,64));
s->addAnimation("walkUp",anim);
anim = new Animation();
anim->setSpriteSheet(*t);
for (int i = 1; i < 8; ++i)
anim->addFrame(sf::IntRect(i * 64,64,64,64));
s->addAnimation("walkLeft",anim);
anim = new Animation();
anim->setSpriteSheet(*t);
for (int i = 1; i < 8; ++i)
anim->addFrame(sf::IntRect(i * 64,128,64,64));
s->addAnimation("walkDown",anim);
//.........这里部分代码省略.........