本文整理汇总了C++中CollisionObject2D::get_shape_count方法的典型用法代码示例。如果您正苦于以下问题:C++ CollisionObject2D::get_shape_count方法的具体用法?C++ CollisionObject2D::get_shape_count怎么用?C++ CollisionObject2D::get_shape_count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CollisionObject2D
的用法示例。
在下文中一共展示了CollisionObject2D::get_shape_count方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: memnew
void CollisionPolygon2D::_add_to_collision_object(Object *p_obj) {
if (unparenting)
return;
CollisionObject2D *co = p_obj->cast_to<CollisionObject2D>();
ERR_FAIL_COND(!co);
if (polygon.size()==0)
return;
bool solids=build_mode==BUILD_SOLIDS;
if (solids) {
//here comes the sun, lalalala
//decompose concave into multiple convex polygons and add them
Vector< Vector<Vector2> > decomp = Geometry::decompose_polygon(polygon);
for(int i=0;i<decomp.size();i++) {
Ref<ConvexPolygonShape2D> convex = memnew( ConvexPolygonShape2D );
convex->set_points(decomp[i]);
co->add_shape(convex,get_transform());
if (trigger)
co->set_shape_as_trigger(co->get_shape_count()-1,true);
}
} else {
Ref<ConcavePolygonShape2D> concave = memnew( ConcavePolygonShape2D );
DVector<Vector2> segments;
segments.resize(polygon.size()*2);
DVector<Vector2>::Write w=segments.write();
for(int i=0;i<polygon.size();i++) {
w[(i<<1)+0]=polygon[i];
w[(i<<1)+1]=polygon[(i+1)%polygon.size()];
}
w=DVector<Vector2>::Write();
concave->set_segments(segments);
co->add_shape(concave,get_transform());
if (trigger)
co->set_shape_as_trigger(co->get_shape_count()-1,true);
}
//co->add_shape(shape,get_transform());
}
示例2:
void CollisionShape2D::_add_to_collision_object(Object *p_obj) {
if (unparenting)
return;
CollisionObject2D *co = p_obj->cast_to<CollisionObject2D>();
ERR_FAIL_COND(!co);
update_shape_index=co->get_shape_count();
co->add_shape(shape,get_transform());
if (trigger)
co->set_shape_as_trigger(co->get_shape_count()-1,true);
}