本文整理汇总了C++中Graphic::get_position方法的典型用法代码示例。如果您正苦于以下问题:C++ Graphic::get_position方法的具体用法?C++ Graphic::get_position怎么用?C++ Graphic::get_position使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graphic
的用法示例。
在下文中一共展示了Graphic::get_position方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
void DebugPart::update(Game& game, Scene* scene, Entity* entity) {
unsigned int graphic_idx = 0;
Graphic* g = nullptr;
GraphicsPart* graphics = dynamic_cast<GraphicsPart*>(entity->get("graphics"));
PhysicsPart* physics = dynamic_cast<PhysicsPart*>(entity->get("physics"));
Layer* layer = nullptr;
// get entity's debug enable
if (entity) {
this->show_text(entity->enable_debug_text());
}
// update size and position of each debug part sprite based on entity's graphic part
if (graphics) {
while ((g = graphics->get(graphic_idx))) {
if (graphic_idx >= this->sprites_.size()) {
Graphic* g_debug = new Shape(new sf::RectangleShape());
g_debug->set_fill_color(sf::Color::Transparent);
g_debug->set_outline_color(sf::Color::Red);
g_debug->set_outline_thickness(1.0);
g_debug->layer(g->layer());
this->sprites_.push_back(g_debug);
}
this->sprites_[graphic_idx]->set_position(g->get_position());
this->sprites_[graphic_idx]->set_size(g->get_size());
layer = g->layer();
++graphic_idx;
}
}
// write down position of entity based on entity's physics part
if (physics && this->show_text()) {
sf::Vector2f pos = physics->get_position();
this->pos_text_->set_string(std::to_string((int)pos.x) + ", " + std::to_string((int)pos.y));
this->pos_text_->set_position(pos);
this->pos_text_->layer(layer);
}
}