pub struct BodyDef { /* private fields */ }Expand description
A struct to describe the properties of a physics body.
Implementations§
Source§impl BodyDef
impl BodyDef
Sourcepub fn set_position(&mut self, val: &Vec2)
pub fn set_position(&mut self, val: &Vec2)
Sets define for the position of the body.
Sourcepub fn get_position(&self) -> Vec2
pub fn get_position(&self) -> Vec2
Gets define for the position of the body.
Sourcepub fn set_face(&mut self, val: &str)
pub fn set_face(&mut self, val: &str)
Sets define for the face image or other items accepted by creating Face for the body.
Sourcepub fn get_face(&self) -> String
pub fn get_face(&self) -> String
Gets define for the face image or other items accepted by creating Face for the body.
Sourcepub fn set_face_pos(&mut self, val: &Vec2)
pub fn set_face_pos(&mut self, val: &Vec2)
Sets define for the face position of the body.
Sourcepub fn get_face_pos(&self) -> Vec2
pub fn get_face_pos(&self) -> Vec2
Gets define for the face position of the body.
Sourcepub fn set_linear_damping(&mut self, val: f32)
pub fn set_linear_damping(&mut self, val: f32)
Sets define for linear damping of the body.
Sourcepub fn get_linear_damping(&self) -> f32
pub fn get_linear_damping(&self) -> f32
Gets define for linear damping of the body.
Sourcepub fn set_angular_damping(&mut self, val: f32)
pub fn set_angular_damping(&mut self, val: f32)
Sets define for angular damping of the body.
Sourcepub fn get_angular_damping(&self) -> f32
pub fn get_angular_damping(&self) -> f32
Gets define for angular damping of the body.
Sourcepub fn set_linear_acceleration(&mut self, val: &Vec2)
pub fn set_linear_acceleration(&mut self, val: &Vec2)
Sets define for initial linear acceleration of the body.
Sourcepub fn get_linear_acceleration(&self) -> Vec2
pub fn get_linear_acceleration(&self) -> Vec2
Gets define for initial linear acceleration of the body.
Sourcepub fn set_fixed_rotation(&mut self, val: bool)
pub fn set_fixed_rotation(&mut self, val: bool)
Sets whether the body’s rotation is fixed or not.
Sourcepub fn is_fixed_rotation(&self) -> bool
pub fn is_fixed_rotation(&self) -> bool
Gets whether the body’s rotation is fixed or not.
Sourcepub fn set_bullet(&mut self, val: bool)
pub fn set_bullet(&mut self, val: bool)
Sets whether the body is a bullet or not. Set to true to add extra bullet movement check for the body.
Sourcepub fn is_bullet(&self) -> bool
pub fn is_bullet(&self) -> bool
Gets whether the body is a bullet or not. Set to true to add extra bullet movement check for the body.
Sourcepub fn polygon_with_center(
center: &Vec2,
width: f32,
height: f32,
angle: f32,
density: f32,
friction: f32,
restitution: f32,
) -> FixtureDef
pub fn polygon_with_center( center: &Vec2, width: f32, height: f32, angle: f32, density: f32, friction: f32, restitution: f32, ) -> FixtureDef
Creates a polygon fixture definition with the specified dimensions and center position.
§Arguments
center- The center point of the polygon.width- The width of the polygon.height- The height of the polygon.angle- The angle of the polygon.density- The density of the polygon.friction- The friction of the polygon. Should be between 0 and 1.0.restitution- The restitution of the polygon. Should be between 0 and 1.
Sourcepub fn polygon(
width: f32,
height: f32,
density: f32,
friction: f32,
restitution: f32,
) -> FixtureDef
pub fn polygon( width: f32, height: f32, density: f32, friction: f32, restitution: f32, ) -> FixtureDef
Creates a polygon fixture definition with the specified dimensions.
§Arguments
width- The width of the polygon.height- The height of the polygon.density- The density of the polygon.friction- The friction of the polygon. Should be between 0 and 1.0.restitution- The restitution of the polygon. Should be between 0 and 1.
Sourcepub fn polygon_with_vertices(
vertices: &Vec<Vec2>,
density: f32,
friction: f32,
restitution: f32,
) -> FixtureDef
pub fn polygon_with_vertices( vertices: &Vec<Vec2>, density: f32, friction: f32, restitution: f32, ) -> FixtureDef
Creates a polygon fixture definition with the specified vertices.
§Arguments
vertices- The vertices of the polygon.density- The density of the polygon.friction- The friction of the polygon. Should be between 0 and 1.0.restitution- The restitution of the polygon. Should be between 0 and 1.0.
Sourcepub fn attach_polygon_with_center(
&mut self,
center: &Vec2,
width: f32,
height: f32,
angle: f32,
density: f32,
friction: f32,
restitution: f32,
)
pub fn attach_polygon_with_center( &mut self, center: &Vec2, width: f32, height: f32, angle: f32, density: f32, friction: f32, restitution: f32, )
Attaches a polygon fixture definition to the body.
§Arguments
center- The center point of the polygon.width- The width of the polygon.height- The height of the polygon.angle- The angle of the polygon.density- The density of the polygon.friction- The friction of the polygon. Should be between 0 and 1.0.restitution- The restitution of the polygon. Should be between 0 and 1.0.
Sourcepub fn attach_polygon(
&mut self,
width: f32,
height: f32,
density: f32,
friction: f32,
restitution: f32,
)
pub fn attach_polygon( &mut self, width: f32, height: f32, density: f32, friction: f32, restitution: f32, )
Attaches a polygon fixture definition to the body.
§Arguments
width- The width of the polygon.height- The height of the polygon.density- The density of the polygon.friction- The friction of the polygon. Should be between 0 and 1.0.restitution- The restitution of the polygon. Should be between 0 and 1.0.
Sourcepub fn attach_polygon_with_vertices(
&mut self,
vertices: &Vec<Vec2>,
density: f32,
friction: f32,
restitution: f32,
)
pub fn attach_polygon_with_vertices( &mut self, vertices: &Vec<Vec2>, density: f32, friction: f32, restitution: f32, )
Attaches a polygon fixture definition to the body.
§Arguments
vertices- The vertices of the polygon.density- The density of the polygon.friction- The friction of the polygon. Should be between 0 and 1.0.restitution- The restitution of the polygon. Should be between 0 and 1.0.
Sourcepub fn multi(
vertices: &Vec<Vec2>,
density: f32,
friction: f32,
restitution: f32,
) -> FixtureDef
pub fn multi( vertices: &Vec<Vec2>, density: f32, friction: f32, restitution: f32, ) -> FixtureDef
Creates a concave shape definition made of multiple convex shapes.
§Arguments
vertices- A vector containing the vertices of each convex shape that makes up the concave shape. Each convex shape in the vertices vector should end with aVec2(0.0, 0.0)as separator.density- The density of the shape.friction- The friction coefficient of the shape. Should be between 0.0 and 1.0.restitution- The restitution (elasticity) of the shape. Should be between 0.0 and 1.0.
§Returns
FixtureDef- The resulting fixture definition.
Sourcepub fn attach_multi(
&mut self,
vertices: &Vec<Vec2>,
density: f32,
friction: f32,
restitution: f32,
)
pub fn attach_multi( &mut self, vertices: &Vec<Vec2>, density: f32, friction: f32, restitution: f32, )
Attaches a concave shape definition made of multiple convex shapes to the body.
§Arguments
vertices- A vector containing the vertices of each convex shape that makes up the concave shape. Each convex shape in the vertices vector should end with aVec2(0.0, 0.0)as separator.density- The density of the concave shape.friction- The friction of the concave shape. Should be between 0.0 and 1.0.restitution- The restitution of the concave shape. Should be between 0.0 and 1.0.
Sourcepub fn disk_with_center(
center: &Vec2,
radius: f32,
density: f32,
friction: f32,
restitution: f32,
) -> FixtureDef
pub fn disk_with_center( center: &Vec2, radius: f32, density: f32, friction: f32, restitution: f32, ) -> FixtureDef
Creates a Disk-shape fixture definition.
§Arguments
center- The center of the circle.radius- The radius of the circle.density- The density of the circle.friction- The friction coefficient of the circle. Should be between 0.0 and 1.0.restitution- The restitution (elasticity) of the circle. Should be between 0.0 and 1.0.
§Returns
FixtureDef- The resulting fixture definition.
Sourcepub fn disk(
radius: f32,
density: f32,
friction: f32,
restitution: f32,
) -> FixtureDef
pub fn disk( radius: f32, density: f32, friction: f32, restitution: f32, ) -> FixtureDef
Creates a Disk-shape fixture definition.
§Arguments
radius- The radius of the circle.density- The density of the circle.friction- The friction coefficient of the circle. Should be between 0.0 and 1.0.restitution- The restitution (elasticity) of the circle. Should be between 0.0 and 1.0.
§Returns
FixtureDef- The resulting fixture definition.
Sourcepub fn attach_disk_with_center(
&mut self,
center: &Vec2,
radius: f32,
density: f32,
friction: f32,
restitution: f32,
)
pub fn attach_disk_with_center( &mut self, center: &Vec2, radius: f32, density: f32, friction: f32, restitution: f32, )
Attaches a disk fixture definition to the body.
§Arguments
center- The center point of the disk.radius- The radius of the disk.density- The density of the disk.friction- The friction of the disk. Should be between 0.0 and 1.0.restitution- The restitution of the disk. Should be between 0.0 and 1.0.
Sourcepub fn attach_disk(
&mut self,
radius: f32,
density: f32,
friction: f32,
restitution: f32,
)
pub fn attach_disk( &mut self, radius: f32, density: f32, friction: f32, restitution: f32, )
Attaches a disk fixture definition to the body.
§Arguments
radius- The radius of the disk.density- The density of the disk.friction- The friction of the disk. Should be between 0.0 and 1.0.restitution- The restitution of the disk. Should be between 0.0 and 1.0.
Sourcepub fn chain(
vertices: &Vec<Vec2>,
friction: f32,
restitution: f32,
) -> FixtureDef
pub fn chain( vertices: &Vec<Vec2>, friction: f32, restitution: f32, ) -> FixtureDef
Creates a Chain-shape fixture definition. This fixture is a free form sequence of line segments that has two-sided collision.
§Arguments
vertices- The vertices of the chain.friction- The friction coefficient of the chain. Should be between 0.0 and 1.0.restitution- The restitution (elasticity) of the chain. Should be between 0.0 and 1.0.
§Returns
FixtureDef- The resulting fixture definition.
Sourcepub fn attach_chain(
&mut self,
vertices: &Vec<Vec2>,
friction: f32,
restitution: f32,
)
pub fn attach_chain( &mut self, vertices: &Vec<Vec2>, friction: f32, restitution: f32, )
Attaches a chain fixture definition to the body. The Chain fixture is a free form sequence of line segments that has two-sided collision.
§Arguments
vertices- The vertices of the chain.friction- The friction of the chain. Should be between 0.0 and 1.0.restitution- The restitution of the chain. Should be between 0.0 and 1.0.
Sourcepub fn attach_polygon_sensor(&mut self, tag: i32, width: f32, height: f32)
pub fn attach_polygon_sensor(&mut self, tag: i32, width: f32, height: f32)
Attaches a polygon sensor fixture definition to the body.
§Arguments
tag- An integer tag for the sensor.width- The width of the polygon.height- The height of the polygon.
Sourcepub fn attach_polygon_sensor_with_center(
&mut self,
tag: i32,
center: &Vec2,
width: f32,
height: f32,
angle: f32,
)
pub fn attach_polygon_sensor_with_center( &mut self, tag: i32, center: &Vec2, width: f32, height: f32, angle: f32, )
Attaches a polygon sensor fixture definition to the body.
§Arguments
tag- An integer tag for the sensor.center- The center point of the polygon.width- The width of the polygon.height- The height of the polygon.angle- Optional. The angle of the polygon.
Sourcepub fn attach_polygon_sensor_with_vertices(
&mut self,
tag: i32,
vertices: &Vec<Vec2>,
)
pub fn attach_polygon_sensor_with_vertices( &mut self, tag: i32, vertices: &Vec<Vec2>, )
Attaches a polygon sensor fixture definition to the body.
§Arguments
tag- An integer tag for the sensor.vertices- A vector containing the vertices of the polygon.
Sourcepub fn attach_disk_sensor_with_center(
&mut self,
tag: i32,
center: &Vec2,
radius: f32,
)
pub fn attach_disk_sensor_with_center( &mut self, tag: i32, center: &Vec2, radius: f32, )
Attaches a disk sensor fixture definition to the body.
§Arguments
tag- An integer tag for the sensor.center- The center of the disk.radius- The radius of the disk.
Sourcepub fn attach_disk_sensor(&mut self, tag: i32, radius: f32)
pub fn attach_disk_sensor(&mut self, tag: i32, radius: f32)
Attaches a disk sensor fixture definition to the body.
§Arguments
tag- An integer tag for the sensor.radius- The radius of the disk.