本文整理汇总了C++中VisualServer::canvas_item_add_line方法的典型用法代码示例。如果您正苦于以下问题:C++ VisualServer::canvas_item_add_line方法的具体用法?C++ VisualServer::canvas_item_add_line怎么用?C++ VisualServer::canvas_item_add_line使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VisualServer
的用法示例。
在下文中一共展示了VisualServer::canvas_item_add_line方法的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: _add_concave
void _add_concave(const Vector<Vector2> &p_points, const Matrix32 &p_xform = Matrix32()) {
Physics2DServer *ps = Physics2DServer::get_singleton();
VisualServer *vs = VisualServer::get_singleton();
RID concave = ps->shape_create(Physics2DServer::SHAPE_CONCAVE_POLYGON);
ps->shape_set_data(concave, p_points);
RID body = ps->body_create(Physics2DServer::BODY_MODE_STATIC);
ps->body_set_space(body, space);
ps->body_add_shape(body, concave);
ps->body_set_state(body, Physics2DServer::BODY_STATE_TRANSFORM, p_xform);
RID sprite = vs->canvas_item_create();
vs->canvas_item_set_parent(sprite, canvas);
vs->canvas_item_set_transform(sprite, p_xform);
for (int i = 0; i < p_points.size(); i += 2) {
vs->canvas_item_add_line(sprite, p_points[i], p_points[i + 1], Color(0, 0, 0), 2);
}
}