本文整理汇总了C++中VisualServer::canvas_item_add_texture_rect方法的典型用法代码示例。如果您正苦于以下问题:C++ VisualServer::canvas_item_add_texture_rect方法的具体用法?C++ VisualServer::canvas_item_add_texture_rect怎么用?C++ VisualServer::canvas_item_add_texture_rect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VisualServer
的用法示例。
在下文中一共展示了VisualServer::canvas_item_add_texture_rect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _add_body
RID _add_body(Physics2DServer::ShapeType p_shape, const Matrix32& p_xform) {
VisualServer *vs = VisualServer::get_singleton();
Physics2DServer *ps = Physics2DServer::get_singleton();
RID body = ps->body_create();
ps->body_add_shape(body,body_shape_data[p_shape].shape);
ps->body_set_space(body,space);
ps->body_set_continuous_collision_detection_mode(body,Physics2DServer::CCD_MODE_CAST_SHAPE);
ps->body_set_state(body,Physics2DServer::BODY_STATE_TRANSFORM,p_xform);
// print_line("add body with xform: "+p_xform);
RID sprite = vs->canvas_item_create();
vs->canvas_item_set_parent(sprite,canvas);
vs->canvas_item_set_transform(sprite,p_xform);
Size2 imgsize( vs->texture_get_width(body_shape_data[p_shape].image),vs->texture_get_height(body_shape_data[p_shape].image) );
vs->canvas_item_add_texture_rect(sprite,Rect2(-imgsize/2.0,imgsize),body_shape_data[p_shape].image);
ps->body_set_force_integration_callback(body,this,"_body_moved",sprite);
// RID q = ps->query_create(this,"_body_moved",sprite);
// ps->query_body_state(q,body);
return body;
}
示例2: _notification
void ScrollBar::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAW) {
RID ci = get_canvas_item();
Ref<Texture> decr = highlight == HIGHLIGHT_DECR ? get_icon("decrement_highlight") : get_icon("decrement");
Ref<Texture> incr = highlight == HIGHLIGHT_INCR ? get_icon("increment_highlight") : get_icon("increment");
Ref<StyleBox> bg = has_focus() ? get_stylebox("scroll_focus") : get_stylebox("scroll");
Ref<StyleBox> grabber;
if (drag.active)
grabber = get_stylebox("grabber_pressed");
else if (highlight == HIGHLIGHT_RANGE)
grabber = get_stylebox("grabber_highlight");
else
grabber = get_stylebox("grabber");
Point2 ofs;
VisualServer *vs = VisualServer::get_singleton();
vs->canvas_item_add_texture_rect(ci, Rect2(Point2(), decr->get_size()), decr->get_rid());
if (orientation == HORIZONTAL)
ofs.x += decr->get_width();
else
ofs.y += decr->get_height();
Size2 area = get_size();
if (orientation == HORIZONTAL)
area.width -= incr->get_width() + decr->get_width();
else
area.height -= incr->get_height() + decr->get_height();
bg->draw(ci, Rect2(ofs, area));
if (orientation == HORIZONTAL)
ofs.width += area.width;
else
ofs.height += area.height;
vs->canvas_item_add_texture_rect(ci, Rect2(ofs, decr->get_size()), incr->get_rid());
Rect2 grabber_rect;
if (orientation == HORIZONTAL) {
grabber_rect.size.width = get_grabber_size();
grabber_rect.size.height = get_size().height;
grabber_rect.position.y = 0;
grabber_rect.position.x = get_grabber_offset() + decr->get_width() + bg->get_margin(MARGIN_LEFT);
} else {
grabber_rect.size.width = get_size().width;
grabber_rect.size.height = get_grabber_size();
grabber_rect.position.y = get_grabber_offset() + decr->get_height() + bg->get_margin(MARGIN_TOP);
grabber_rect.position.x = 0;
}
grabber->draw(ci, grabber_rect);
}
if (p_what == NOTIFICATION_ENTER_TREE) {
if (has_node(drag_slave_path)) {
Node *n = get_node(drag_slave_path);
drag_slave = n->cast_to<Control>();
}
if (drag_slave) {
drag_slave->connect("gui_input", this, "_drag_slave_input");
drag_slave->connect("tree_exited", this, "_drag_slave_exit", varray(), CONNECT_ONESHOT);
}
}
if (p_what == NOTIFICATION_EXIT_TREE) {
if (drag_slave) {
drag_slave->disconnect("gui_input", this, "_drag_slave_input");
drag_slave->disconnect("tree_exited", this, "_drag_slave_exit");
}
drag_slave = NULL;
}
if (p_what == NOTIFICATION_FIXED_PROCESS) {
if (scrolling) {
if (get_value() != target_scroll) {
double target = target_scroll - get_value();
double dist = sqrt(target * target);
double vel = ((target / dist) * 500) * get_fixed_process_delta_time();
if (vel >= dist) {
set_value(target_scroll);
} else {
set_value(get_value() + vel);
}
} else {
scrolling = false;
//.........这里部分代码省略.........