本文整理汇总了C++中AssetManager::getAssetPointer方法的典型用法代码示例。如果您正苦于以下问题:C++ AssetManager::getAssetPointer方法的具体用法?C++ AssetManager::getAssetPointer怎么用?C++ AssetManager::getAssetPointer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AssetManager
的用法示例。
在下文中一共展示了AssetManager::getAssetPointer方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: XmlException
//===========================================
// PauseMenu::PauseMenu
//===========================================
PauseMenu::PauseMenu(const XmlNode data)
: Asset(internString("PauseMenu")),
Entity(data.firstChild().firstChild().firstChild()),
Menu(data.firstChild()) {
try {
AssetManager assetManager;
XML_NODE_CHECK(data, PauseMenu);
XmlNode node = data.nthChild(1);
XML_NODE_CHECK(node, flare);
XmlAttribute attr = node.firstAttribute();
XML_ATTR_CHECK(attr, ptr);
long id = attr.getLong();
m_flare = boost::dynamic_pointer_cast<CSprite>(assetManager.getAssetPointer(id));
if (!m_flare)
throw XmlException("Bad asset id for flare item", __FILE__, __LINE__);
m_flare->addToWorld();
}
catch (XmlException& e) {
e.prepend("Error parsing XML for instance of class PauseMenu; ");
throw;
}
}
示例2: XmlException
//===========================================
// CreditsMenu::CreditsMenu
//===========================================
CreditsMenu::CreditsMenu(const XmlNode data)
: Asset(internString("CreditsMenu")),
Entity(data.firstChild().firstChild().firstChild()),
Menu(data.firstChild()) {
try {
AssetManager assetManager;
XML_NODE_CHECK(data, CreditsMenu);
XmlNode node = data.nthChild(1);
XML_NODE_CHECK(node, font);
XmlAttribute attr = node.firstAttribute();
XML_ATTR_CHECK(attr, ptr);
long id = attr.getLong();
m_font = boost::dynamic_pointer_cast<Dodge::Font>(assetManager.getAssetPointer(id));
if (!m_font)
throw XmlException("Bad font asset id", __FILE__, __LINE__);
node = node.nextSibling();
XML_NODE_CHECK(node, fadeInTime);
m_fadeInTime = node.getFloat();
}
catch (XmlException& e) {
e.prepend("Error parsing XML for instance of class CreditsMenu; ");
throw;
}
init();
}
示例3: XmlException
//===========================================
// TextEntity::TextEntity
//===========================================
TextEntity::TextEntity(const XmlNode data)
: Asset(internString("TextEntity")),
Entity(data.firstChild()),
m_renderer(Renderer::getInstance()),
m_model(Renderer::TRIANGLES) {
try {
XML_NODE_CHECK(data, TextEntity);
XmlNode node = data.nthChild(1);
XML_NODE_CHECK(node, font);
XmlAttribute attr = node.firstAttribute();
XML_ATTR_CHECK(attr, ptr);
long fontId = attr.getLong();
AssetManager assetManager;
pFont_t font = boost::dynamic_pointer_cast<Dodge::Font>(assetManager.getAssetPointer(fontId));
if (!font)
throw XmlException("Bad asset id", __FILE__, __LINE__);
m_font = font;
node = node.nextSibling();
XML_NODE_CHECK(node, textSize);
m_size = Vec2f(node.firstChild());
node = node.nextSibling();
XML_NODE_CHECK(node, text);
setText(node.getString());
}
catch (XmlException& e) {
e.prepend("Error parsing XML for instance of class TextEntity; ");
throw;
}
}
示例4: assignData
//===========================================
// TextEntity::assignData
//===========================================
void TextEntity::assignData(const XmlNode data) {
try {
if (data.isNull() || data.name() != "TextEntity") return;
XmlNode node = data.nthChild(1);
if (!node.isNull() && node.name() == "font") {
XmlAttribute attr = node.firstAttribute();
if (!attr.isNull() && attr.name() == "ptr") {
long fontId = attr.getLong();
AssetManager assetManager;
pFont_t font = boost::dynamic_pointer_cast<Dodge::Font>(assetManager.getAssetPointer(fontId));
if (!font)
throw XmlException("Bad asset id", __FILE__, __LINE__);
m_font = font;
}
node = node.nextSibling();
}
if (!node.isNull() && node.name() == "textSize") {
m_size = Vec2f(node.firstChild());
node = node.nextSibling();
}
XML_NODE_CHECK(node, text);
setText(node.getString());
}
catch (XmlException& e) {
e.prepend("Error parsing XML for instance of class TextEntity; ");
throw;
}
}
示例5: XmlException
//===========================================
// Entity::Entity
//===========================================
Entity::Entity(const XmlNode data)
: Asset(internString("Entity")),
m_silent(false),
m_parent(NULL) {
AssetManager assetManager;
ShapeFactory shapeFactory;
try {
setSilent(true);
XML_NODE_CHECK(data, Entity);
XmlAttribute attr = data.firstAttribute();
XML_ATTR_CHECK(attr, type);
m_type = internString(attr.getString());
attr = attr.nextAttribute();
XML_ATTR_CHECK(attr, name);
m_name = internString(attr.getString());
attr = attr.nextAttribute();
XML_ATTR_CHECK(attr, x);
m_transl.x = attr.getFloat();
attr = attr.nextAttribute();
XML_ATTR_CHECK(attr, y);
m_transl.y = attr.getFloat();
attr = attr.nextAttribute();
XML_ATTR_CHECK(attr, z);
m_z = attr.getFloat();
// So that no Z values are 'exactly' equal
m_z += 0.1f * static_cast<float32_t>(rand()) / static_cast<float32_t>(RAND_MAX);
attr = attr.nextAttribute();
XML_ATTR_CHECK(attr, rot);
float32_t rot = attr.getFloat();
XmlNode node = data.firstChild();
if (!node.isNull() && node.name() == "shape") {
m_shape = unique_ptr<Shape>(shapeFactory.create(node.firstChild()));
node = node.nextSibling();
}
m_rot = 0;
setRotation(rot);
XML_NODE_CHECK(node, scale);
m_scale = Vec2f(1.f, 1.f);
setScale(Vec2f(node.firstChild()));
node = node.nextSibling();
XML_NODE_CHECK(node, fillColour);
m_fillColour = Colour(node.firstChild());
node = node.nextSibling();
XML_NODE_CHECK(node, lineColour);
m_lineColour = Colour(node.firstChild());
node = node.nextSibling();
XML_NODE_CHECK(node, lineWidth);
m_lineWidth = node.getInt();
node = node.nextSibling();
XML_NODE_CHECK(node, children);
XmlNode node_ = node.firstChild();
while (!node_.isNull() && node_.name() == "child") {
XmlAttribute attr = node_.firstAttribute();
if (!attr.isNull() && attr.name() == "ptr") {
long id = attr.getLong();
pEntity_t child = boost::dynamic_pointer_cast<Entity>(assetManager.getAssetPointer(id));
if (!child)
throw XmlException("Bad entity asset id", __FILE__, __LINE__);
addChild(child);
}
node_ = node_.nextSibling();
}
setSilent(false);
++m_count;
}
catch (XmlException& e) {
e.prepend("Error parsing XML for instance of class Entity; ");
throw;
}
recomputeBoundary();
}
示例6: assignData
//===========================================
// Entity::assignData
//===========================================
void Entity::assignData(const XmlNode data) {
if (data.isNull() || data.name() != "Entity") return;
AssetManager assetManager;
ShapeFactory shapeFactory;
try {
bool silent = isSilent();
setSilent(true);
XmlAttribute attr = data.firstAttribute();
if (!attr.isNull() && attr.name() == "type") {
m_type = internString(attr.getString());
attr = attr.nextAttribute();
}
if (!attr.isNull() && attr.name() == "name") {
m_name = internString(attr.getString());
attr = attr.nextAttribute();
}
Vec2f transl = m_transl;
if (!attr.isNull() && attr.name() == "x") {
transl.x = attr.getFloat();
attr = attr.nextAttribute();
}
if (!attr.isNull() && attr.name() == "y") {
transl.y = attr.getFloat();
attr = attr.nextAttribute();
}
setTranslation(transl);
if (!attr.isNull() && attr.name() == "z") {
m_z = attr.getFloat();
// So that no Z values are 'exactly' equal
m_z += 0.1f * static_cast<float32_t>(rand()) / static_cast<float32_t>(RAND_MAX);
attr = attr.nextAttribute();
}
XmlNode node = data.firstChild();
if (!node.isNull() && node.name() == "shape") {
m_shape = unique_ptr<Shape>(shapeFactory.create(node.firstChild()));
node = node.nextSibling();
}
if (!node.isNull() && node.name() == "scale") {
setScale(Vec2f(node.firstChild()));
node = node.nextSibling();
}
if (!attr.isNull() && attr.name() == "rot") {
setRotation(attr.getFloat());
}
if (!node.isNull() && node.name() == "fillColour") {
m_fillColour = Colour(node.firstChild());
node = node.nextSibling();
}
if (!node.isNull() && node.name() == "lineColour") {
m_lineColour = Colour(node.firstChild());
node = node.nextSibling();
}
if (!node.isNull() && node.name() == "lineWidth") {
m_lineWidth = node.getInt();
node = node.nextSibling();
}
if (!node.isNull() && node.name() == "children") {
XmlNode node_ = node.firstChild();
while (!node_.isNull() && node_.name() == "child") {
XmlAttribute attr = node_.firstAttribute();
if (!attr.isNull() && attr.name() == "ptr") {
long id = attr.getLong();
pEntity_t child = boost::dynamic_pointer_cast<Entity>(assetManager.getAssetPointer(id));
if (!child)
throw XmlException("Bad entity asset id", __FILE__, __LINE__);
addChild(child);
}
node_ = node_.nextSibling();
}
}
setSilent(silent);
}
//.........这里部分代码省略.........