本文整理汇总了C++中AssetManager::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ AssetManager::Add方法的具体用法?C++ AssetManager::Add怎么用?C++ AssetManager::Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AssetManager
的用法示例。
在下文中一共展示了AssetManager::Add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[]) {
sf::RenderWindow window(sf::VideoMode(WIDTH, HEIGHT), "SpaceGameThing");
sf::Clock clock;
sf::Clock physClock;
float dt;
HeavenlyBody* planet = new HeavenlyBody(0.25, 25000, QUIET);
planet->Load("../bin/planet.png");
planet->SetPosition(WIDTH/2, 95);
planet->SetCollidable(true);
//planet->SetOrigin(95,95);
planet->SetColor(sf::Color(255, 0, 0, 255));
HitBoxBase<std::pair<sf::Vector2f, float> > hbox(std::pair<sf::Vector2f, float>(sf::Vector2f(95, 95), planet->GetRadius()));
planet->SetHitBox((void*)(&hbox), collision::RADIAL);
HeavenlyBody* planet2 = new HeavenlyBody(2.0, 200000, QUIET);
planet2->Load("../bin/planet.png");
planet2->SetPosition(WIDTH/2, HEIGHT+90);
planet2->SetCollidable(true);
//planet2->SetOrigin(95,95);
planet2->SetColor(sf::Color(255, 0, 0, 255));
HitBoxBase<std::pair<sf::Vector2f, float> > hbox2(std::pair<sf::Vector2f, float>(sf::Vector2f(95, 95), planet2->GetRadius()));
planet2->SetHitBox((void*)(&hbox2), collision::RADIAL);
HeavenlyBody* planet3 = new HeavenlyBody(0.5, 20000, QUIET);
planet3->Load("../bin/planet.png");
planet3->SetPosition(WIDTH/4, 90);
planet3->SetCollidable(true);
//planet3->SetOrigin(95,95);
planet3->SetColor(sf::Color(255, 0, 0, 255));
HitBoxBase<std::pair<sf::Vector2f, float> > hbox3(std::pair<sf::Vector2f, float>(sf::Vector2f(95, 95), planet3->GetRadius()));
planet3->SetHitBox((void*)(&hbox3), collision::RADIAL);
//test a compound asset
CompoundAsset* cst = new CompoundAsset();
cst->Load("../bin/scripts/assets/test.ass");
cst->SetOrigin(256, 256);
cst->SetPosition(WIDTH/2, HEIGHT/2);
cst->setMass(100000.0);
cst->SetScale(0.25, 0.25);
AssetManager manager;
PhysicsManager physManager;
manager.Add("planet", planet);
manager.Add("planet2", planet2);
manager.Add("planet3", planet3);
manager.Add("cst", cst);
//manager.Add("redPlanet", surface);
physManager.Add(cst);
physManager.Add(planet);
physManager.Add(planet2);
physManager.Add(planet3);
physManager.InitPhysVec();
QuadTree QT(-3/2*WIDTH, 0, 3*WIDTH, HEIGHT);
//QT.AddGeometry(*surface);
WorldGeometry* Geoms[30];
std::string name = "surface";
std::string index;
std::string fin;
std::stringstream num (std::stringstream::in | std::stringstream::out);
for (int i = 0; i < 30; ++i) {
Geoms[i] = new WorldGeometry();
Geoms[i]->Load("../bin/planet.png");
Geoms[i]->SetPosition(192*(i-15), HEIGHT - 190);
Geoms[i]->SetCollidable(true);
Geoms[i]->SetOrigin(95,95);
QT.AddGeometry(*Geoms[i]);
num << i;
index = num.str();
num.str("");
fin = name + index;
manager.Add(fin, Geoms[i]);
}
/*
WorldGeometry* surface = new WorldGeometry();
surface->Load("../bin/planet.png");
surface->SetPosition(0, HEIGHT-190);
surface->SetCollidable(true);
surface->SetOrigin(95,95);
*/
planet->setVx(-180);
planet->setVy(-40.0);
planet2->setVx(50);
int nFrames = 0;
sf::Clock fClock;
sf::Font font; //make a frame counter in a class later
font.loadFromFile("../bin/DroidSans.tff");
sf::Text Fps("0", font, 14);
std::stringstream ss (std::stringstream::in | std::stringstream::out);
//.........这里部分代码省略.........