Skip to main content

create_polygon_shape

Function create_polygon_shape 

Source
pub fn create_polygon_shape(
    world: &mut World,
    body_id: BodyId,
    def: &ShapeDef,
    polygon: &Polygon,
) -> ShapeId
Expand description

(b2CreatePolygonShape)

Examples found in repository?
examples/demo_scenes.rs (line 16)
10fn add_static_box(world: &mut World, x: f32, y: f32, hx: f32, hy: f32) -> i32 {
11    let mut body_def = default_body_def();
12    body_def.position = m::to_pos(m::Vec2 { x, y });
13    let id = create_body(world, &body_def);
14    let def = default_shape_def();
15    let poly = make_box(hx, hy);
16    create_polygon_shape(world, id, &def, &poly);
17    get_body_full_id(world, id)
18}
19
20fn add_box(world: &mut World, x: f32, y: f32, hx: f32, hy: f32) -> i32 {
21    let mut body_def = default_body_def();
22    body_def.type_ = BodyType::Dynamic;
23    body_def.position = m::to_pos(m::Vec2 { x, y });
24    let id = create_body(world, &body_def);
25    let mut def = default_shape_def();
26    def.density = 1.0;
27    def.material.friction = 0.3;
28    let poly = make_box(hx, hy);
29    create_polygon_shape(world, id, &def, &poly);
30    get_body_full_id(world, id)
31}