本文整理汇总了C++中Box2f::contains方法的典型用法代码示例。如果您正苦于以下问题:C++ Box2f::contains方法的具体用法?C++ Box2f::contains怎么用?C++ Box2f::contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Box2f
的用法示例。
在下文中一共展示了Box2f::contains方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
void LayersDialog::update(float elapsed_time) {
if (layering() == NULL) return;
vector< DialogBin > &bins = layering()->bins;
float &dialog_tween = layering()->dialog_tween;
dialog_tween += elapsed_time;
if (dialog_tween > 1.0f) dialog_tween = 1.0f;
for (unsigned int b = 0; b < bins.size(); ++b) {
Box2f box = bins[b].get_box(dialog_tween);
if (box.contains(mouse_pos)) {
bins[b].arrows += elapsed_time * 4.0f;
if (bins[b].arrows > 1.0f) bins[b].arrows = 1.0f;
} else {
bins[b].arrows -= elapsed_time * 1.5f;
if (bins[b].arrows < 0.0f) bins[b].arrows = 0.0f;
}
Box2f tex = bins[b].get_tex_box(dialog_tween);
if (tex.contains(mouse_pos)) {
bins[b].zoom_out += elapsed_time * 3.0f;
if (bins[b].zoom_out > 1.0f) bins[b].zoom_out = 1.0f;
} else {
bins[b].zoom_out -= elapsed_time * 3.0f;
if (bins[b].zoom_out < 0.0f) bins[b].zoom_out = 0.0f;
}
}
}
示例2: handle_event
bool LayersDialog::handle_event(SDL_Event const &event, Vector2f local_mouse) {
mouse_pos = local_mouse;
if (layering() == NULL) return false;
if (event.type == SDL_MOUSEBUTTONDOWN) {
vector< DialogBin > const &bins = layering()->bins;
ListGraph &stacking = layering()->stacking;
const float dialog_tween = layering()->dialog_tween;
const vector< vector< uint32_t > > &layers = layering()->layers;
const Vector2ui dialog_point = layering()->dialog_point;
const vector< uint32_t > &tags = layering()->tags;
const unsigned int width = layering()->width;
const unsigned int height = layering()->height;
for (unsigned int b = 0; b < bins.size(); ++b) {
Box2f box = bins[b].get_box(dialog_tween);
if (box.contains(local_mouse)) {
if (bins[b].layer >= layers.size()) continue;
bool up = local_mouse.y > box.center().y;
if (dialog_point.x < width && dialog_point.y < height && tags.size() == width * height) {
unsigned int t = tags[dialog_point.y * width + dialog_point.x];
assert(t < stacking.lists.size());
for (unsigned int i = 0; i < stacking.lists[t].size(); ++i) {
if (stacking.lists[t][i] == bins[b].layer) {
if (up && i + 1 < stacking.lists[t].size()) {
stacking.flip_rel(t, bins[b].layer, stacking.lists[t][i+1], true);
layering()->update_image();
}
if (!up && i - 1 < stacking.lists[t].size()) {
stacking.flip_rel(t, bins[b].layer, stacking.lists[t][i-1], false);
layering()->update_image();
}
break;
}
}
}
return true;
}
}
}
return false;
}