本文整理汇总了C++中VisualServer::canvas_item_clear方法的典型用法代码示例。如果您正苦于以下问题:C++ VisualServer::canvas_item_clear方法的具体用法?C++ VisualServer::canvas_item_clear怎么用?C++ VisualServer::canvas_item_clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VisualServer
的用法示例。
在下文中一共展示了VisualServer::canvas_item_clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _ray_query_callback
void _ray_query_callback(const RID &p_rid, ObjectID p_id, int p_shape, const Vector2 &p_point, const Vector2 &p_normal) {
Vector2 ray_end;
if (p_rid.is_valid()) {
ray_end = p_point;
} else {
ray_end = ray_to;
}
VisualServer *vs = VisualServer::get_singleton();
vs->canvas_item_clear(ray);
vs->canvas_item_add_line(ray, ray_from, ray_end, p_rid.is_valid() ? Color(0, 1, 0.4) : Color(1, 0.4, 0), 2);
if (p_rid.is_valid())
vs->canvas_item_add_line(ray, ray_end, ray_end + p_normal * 20, p_rid.is_valid() ? Color(0, 1, 0.4) : Color(1, 0.4, 0), 2);
}
示例2: _update_dirty_quadrants
void TileMap::_update_dirty_quadrants() {
if (!pending_update)
return;
if (!is_inside_scene())
return;
if (!tile_set.is_valid())
return;
VisualServer *vs = VisualServer::get_singleton();
Physics2DServer *ps = Physics2DServer::get_singleton();
while (dirty_quadrant_list.first()) {
Quadrant &q = *dirty_quadrant_list.first()->self();
vs->canvas_item_clear(q.canvas_item);
ps->body_clear_shapes(q.static_body);
for(int i=0;i<q.cells.size();i++) {
Map<PosKey,Cell>::Element *E=tile_map.find( q.cells[i] );
Cell &c=E->get();
//moment of truth
if (!tile_set->has_tile(c.id))
continue;
Ref<Texture> tex = tile_set->tile_get_texture(c.id);
Vector2 tile_ofs = tile_set->tile_get_texture_offset(c.id);
Vector2 offset = Point2( E->key().x, E->key().y )*cell_size - q.pos;
if (!tex.is_valid())
continue;
Rect2 r = tile_set->tile_get_region(c.id);
Size2 s = tex->get_size();
if (r==Rect2())
s = tex->get_size();
else {
s = r.size;
r.pos.x+=fp_adjust;
r.pos.y+=fp_adjust;
r.size.x-=fp_adjust*2.0;
r.size.y-=fp_adjust*2.0;
}
Rect2 rect;
rect.pos=offset.floor();
rect.size=s;
rect.size.x+=fp_adjust;
rect.size.y+=fp_adjust;
if (c.flip_h)
rect.size.x=-rect.size.x;
if (c.flip_v)
rect.size.y=-rect.size.y;
rect.pos+=tile_ofs;
if (r==Rect2()) {
tex->draw_rect(q.canvas_item,rect);
} else {
tex->draw_rect_region(q.canvas_item,rect,r);
}
Vector< Ref<Shape2D> > shapes = tile_set->tile_get_shapes(c.id);
for(int i=0;i<shapes.size();i++) {
Ref<Shape2D> shape = shapes[i];
if (shape.is_valid()) {
Vector2 shape_ofs = tile_set->tile_get_shape_offset(c.id);
Matrix32 xform;
xform.set_origin(offset.floor()+shape_ofs);
if (c.flip_h) {
xform.elements[0]=-xform.elements[0];
xform.elements[2].x+=s.x;
}
if (c.flip_v) {
xform.elements[1]=-xform.elements[1];
xform.elements[2].y+=s.y;
}
ps->body_add_shape(q.static_body,shape->get_rid(),xform);
}
}
}
dirty_quadrant_list.remove( dirty_quadrant_list.first() );
}
//.........这里部分代码省略.........