BodyDef

Struct BodyDef 

Source
pub struct BodyDef { /* private fields */ }
Expand description

A struct to describe the properties of a physics body.

Implementations§

Source§

impl BodyDef

Source

pub fn set_type(&mut self, body_type: BodyType)

Sets the define for the type of the body.

§Arguments
  • body_type - The type of the body.
Source

pub fn get_type(&self) -> BodyType

Gets the define for the type of the body.

§Returns
  • BodyType - The type of the body.
Source

pub fn set_position(&mut self, val: &Vec2)

Sets define for the position of the body.

Source

pub fn get_position(&self) -> Vec2

Gets define for the position of the body.

Source

pub fn set_angle(&mut self, val: f32)

Sets define for the angle of the body.

Source

pub fn get_angle(&self) -> f32

Gets define for the angle of the body.

Source

pub fn set_face(&mut self, val: &str)

Sets define for the face image or other items accepted by creating Face for the body.

Source

pub fn get_face(&self) -> String

Gets define for the face image or other items accepted by creating Face for the body.

Source

pub fn set_face_pos(&mut self, val: &Vec2)

Sets define for the face position of the body.

Source

pub fn get_face_pos(&self) -> Vec2

Gets define for the face position of the body.

Source

pub fn set_linear_damping(&mut self, val: f32)

Sets define for linear damping of the body.

Source

pub fn get_linear_damping(&self) -> f32

Gets define for linear damping of the body.

Source

pub fn set_angular_damping(&mut self, val: f32)

Sets define for angular damping of the body.

Source

pub fn get_angular_damping(&self) -> f32

Gets define for angular damping of the body.

Source

pub fn set_linear_acceleration(&mut self, val: &Vec2)

Sets define for initial linear acceleration of the body.

Source

pub fn get_linear_acceleration(&self) -> Vec2

Gets define for initial linear acceleration of the body.

Source

pub fn set_fixed_rotation(&mut self, val: bool)

Sets whether the body’s rotation is fixed or not.

Source

pub fn is_fixed_rotation(&self) -> bool

Gets whether the body’s rotation is fixed or not.

Source

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.

Source

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.

Source

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.
Source

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.
Source

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.
Source

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.
Source

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.
Source

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.
Source

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 a Vec2(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.
Source

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 a Vec2(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.
Source

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.
Source

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.
Source

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.
Source

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.
Source

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.
Source

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.
Source

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.
Source

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.
Source

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.
Source

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.
Source

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.
Source

pub fn new() -> BodyDef

Creates a new instance of BodyDef class.

§Returns
  • A new BodyDef object.

Trait Implementations§

Source§

impl Clone for BodyDef

Source§

fn clone(&self) -> BodyDef

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Drop for BodyDef

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl IObject for BodyDef

Source§

fn raw(&self) -> i64

Source§

fn obj(&self) -> &dyn IObject

Source§

fn as_any(&self) -> &dyn Any

Source§

fn get_id(&self) -> i32

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.