本文整理汇总了C++中Anim::play方法的典型用法代码示例。如果您正苦于以下问题:C++ Anim::play方法的具体用法?C++ Anim::play怎么用?C++ Anim::play使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Anim
的用法示例。
在下文中一共展示了Anim::play方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onInit
void MyAppli::onInit () {
Network::startCli(10'000, 10'001,sf::IpAddress::LocalHost);
TextureManager<> &tm = cache.resourceManager<Texture, std::string>("TextureManager");
Vec2f pos (getView().getPosition().x - getView().getSize().x * 0.5f, getView().getPosition().y - getView().getSize().y * 0.5f);
BoundingBox bx (pos.x, pos.y, 0, getView().getSize().x, getView().getSize().y, 0);
theMap = new Map(&getRenderComponentManager(), "Map test", 100, 50);
BaseChangementMatrix bcm;
bcm.set2DIsoMatrix();
theMap->setBaseChangementMatrix(bcm);
World::addEntityManager(theMap);
World::setCurrentEntityManager("Map test");
eu = new EntitiesUpdater(false);
World::addWorker(eu);
au = new AnimUpdater(false);
au->setInterval(sf::seconds(0.01f));
World::addTimer(au);
tiles.push_back(new Tile(tm.getResourceByAlias("GRASS"), Vec3f(0, 0, 0), Vec3f(120, 60, 0),sf::IntRect(0, 0, 100, 50)));
walls.push_back(new Tile(tm.getResourceByAlias("WALLS"), Vec3f(0, 0, 0), Vec3f(100, 100, 0), sf::IntRect(100, 0, 100, 100)));
walls.push_back(new Tile(tm.getResourceByAlias("WALLS"), Vec3f(0, 0, 0), Vec3f(100, 100, 0), sf::IntRect(100, 100, 100, 100)));
walls.push_back(new Tile(tm.getResourceByAlias("WALLS"), Vec3f(0, 0, 0), Vec3f(100, 100, 0), sf::IntRect(100, 200, 100, 100)));
walls.push_back(new Tile(tm.getResourceByAlias("WALLS"), Vec3f(0, 0, 0), Vec3f(100, 100, 0), sf::IntRect(100, 300, 100, 100)));
walls.push_back(new Tile(tm.getResourceByAlias("WALLS"), Vec3f(0, 0, 0), Vec3f(100, 100, 0), sf::IntRect(100, 400, 100, 100)));
walls.push_back(new Tile(tm.getResourceByAlias("WALLS"), Vec3f(0, 0, 0), Vec3f(100, 100, 0), sf::IntRect(100, 500, 100, 100)));
tiles[0]->getFaces()[0]->getMaterial().setTexId("GRASS");
walls[0]->getFaces()[0]->getMaterial().setTexId("WALLS");
walls[1]->getFaces()[0]->getMaterial().setTexId("WALLS");
walls[2]->getFaces()[0]->getMaterial().setTexId("WALLS");
walls[3]->getFaces()[0]->getMaterial().setTexId("WALLS");
walls[4]->getFaces()[0]->getMaterial().setTexId("WALLS");
walls[5]->getFaces()[0]->getMaterial().setTexId("WALLS");
std::ifstream ifs("FichierDeSerialisation");
BoundingBox mapZone(0, 0, 0, 1500, 1000, 0);
World::generate_map(tiles, walls, Vec2f(100, 50), mapZone, false);
w = new g2d::Wall(3, 80, walls[3],&g2d::AmbientLight::getAmbientLight(), Shadow::SHADOW_TYPE::SHADOW_TILE);
w->setPosition(Vec3f(0, 130, 130 + w->getSize().y * 0.5f));
World::addEntity(w);
Tile* thouse = new Tile(tm.getResourceByAlias("HOUSE"), Vec3f(0, 0, 0), Vec3f(250, 300, 0), sf::IntRect(0, 0, 250, 300));
thouse->getFaces()[0]->getMaterial().setTexId("HOUSE");
g2d::Decor* decor = new g2d::Decor(thouse, &g2d::AmbientLight::getAmbientLight(), 300, Shadow::SHADOW_TYPE::SHADOW_TILE);
decor->setPosition(Vec3f(-100, 250, 400));
BoundingVolume *bb = new BoundingBox(decor->getGlobalBounds().getPosition().x, decor->getGlobalBounds().getPosition().y + decor->getGlobalBounds().getSize().y * 0.4f, 0,
decor->getGlobalBounds().getSize().x, decor->getGlobalBounds().getSize().y * 0.25f, 0);
decor->setCollisionVolume(bb);
decor->setShadowCenter(Vec3f(-10, 500, 0));
World::addEntity(decor);
Anim* fire = new Anim(0.1f, Vec3f(0, 100, 150), Vec3f(100, 100, 0), 0);
Tile* tf1 = new Tile(tm.getResourceByAlias("FIRE1"), Vec3f(0, 100, 150), Vec3f(100, 100, 0), sf::IntRect(0, 0, 150, 200));
tf1->getFaces()[0]->getMaterial().setTexId("FIRE1");
g2d::Decor *fire1 = new g2d::Decor(tf1, &g2d::AmbientLight::getAmbientLight(), 100, Shadow::SHADOW_TYPE::SHADOW_TILE);
fire1->setShadowCenter(Vec3f(0, 400, 0));
//decor->setShadowCenter(Vec2f(0, 60));
//decor->changeGravityCenter(Vec3f(50, 50, 0));
Tile* tf2 = new Tile(tm.getResourceByAlias("FIRE2"), Vec3f(0, 100, 150), Vec3f(100, 100, 0), sf::IntRect(0, 0, 150, 200));
tf2->getFaces()[0]->getMaterial().setTexId("FIRE2");
g2d::Decor *fire2 = new g2d::Decor(tf2, &g2d::AmbientLight::getAmbientLight(), 100, Shadow::SHADOW_TYPE::SHADOW_TILE);
fire2->setShadowCenter(Vec3f(0, 400, 0));
//decor->setShadowCenter(Vec2f(0, 60));
//decor->changeGravityCenter(Vec3f(50, 50, 0));
Tile* tf3 = new Tile(tm.getResourceByAlias("FIRE3"), Vec3f(0, 100, 150), Vec3f(100, 100, 0), sf::IntRect(0, 0, 150, 200));
tf3->getFaces()[0]->getMaterial().setTexId("FIRE3");
g2d::Decor *fire3 = new g2d::Decor(tf3, &g2d::AmbientLight::getAmbientLight(), 100, Shadow::SHADOW_TYPE::SHADOW_TILE);
fire3->setShadowCenter(Vec3f(0, 400, 0));
//decor->setShadowCenter(Vec2f(0, 60));
//decor->changeGravityCenter(Vec3f(50, 50, 0));
//fire1->setShadowCenter(Vec2f(80, 100));
//fire2->setShadowCenter(Vec2f(80, 100));
//fire3->setShadowCenter(Vec2f(80, 100));
fire->addFrame(fire1);
fire->addFrame(fire2);
fire->addFrame(fire3);
fire->play(true);
World::addEntity(fire);
au->addAnim(fire);
//PonctualLight* light = new PonctualLight(Vec2f(50, 150),100,50,0,200,sf::Color(255,255,0),16,0);
//World::addEntity(light);
SymEncPacket packet;
packet<<"GETCARINFOS";
Network::sendTcpPacket(packet);
std::string response = Network::waitForLastResponse("CARINFOS", sf::seconds(10.f));
std::istringstream iss(response);
ITextArchive ia(iss);
ia(hero);
std::string path = "tilesets/vlad_sword.png";
cache.resourceManager<Texture, std::string>("TextureManager").fromFileWithAlias(path, "VLADSWORD");
const Texture *text = cache.resourceManager<Texture, std::string>("TextureManager").getResourceByPath(path);
int textRectX = 0, textRectY = 0, textRectWidth = 50, textRectHeight = 100;
int textWidth = text->getSize().x;
Vec3f tmpCenter = hero->getCenter();
hero->setCenter(Vec3f(0, 0, 0));
for (unsigned int i = 0; i <= 56; i+=8) {
Anim* animation = new Anim(0.1f, Vec3f(-25, -50, 0), Vec3f(50, 100, 0), 0);
for (unsigned int j = 0; j < 8; j++) {
sf::IntRect textRect (textRectX, textRectY, textRectWidth, textRectHeight);
Tile *tile = new Tile(text, Vec3f(-25, -50, 0), Vec3f(50, 100, 0), textRect);
tile->getFaces()[0]->getMaterial().setTexId("VLADSWORD");
g2d::Decor *frame = new g2d::Decor(tile, &g2d::AmbientLight::getAmbientLight(), 100, Shadow::SHADOW_TYPE::SHADOW_TILE);
frame->setShadowCenter(Vec3f(0, 100, 0));
//decor->setShadowCenter(Vec2f(80, 130));
//decor->changeGravityCenter(Vec3f(50, 50, 0));
textRectX += textRectWidth;
//.........这里部分代码省略.........