PlatformCamera

Struct PlatformCamera 

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

A platform camera for 2D platformer games that can track a game unit’s movement and keep it within the camera’s view.

Implementations§

Source§

impl PlatformCamera

Source

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

Sets The camera’s position.

Source

pub fn get_position(&self) -> Vec2

Gets The camera’s position.

Source

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

Sets The camera’s rotation in degrees.

Source

pub fn get_rotation(&self) -> f32

Gets The camera’s rotation in degrees.

Source

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

Sets The camera’s zoom factor, 1.0 means the normal size, 2.0 mean zoom to doubled size.

Source

pub fn get_zoom(&self) -> f32

Gets The camera’s zoom factor, 1.0 means the normal size, 2.0 mean zoom to doubled size.

Source

pub fn set_boundary(&mut self, val: &Rect)

Sets The rectangular area within which the camera is allowed to view.

Source

pub fn get_boundary(&self) -> Rect

Gets The rectangular area within which the camera is allowed to view.

Source

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

Sets the ratio at which the camera should move to keep up with the target’s position. For example, set to Vec2(1.0, 1.0), then the camera will keep up to the target’s position right away. Set to Vec2(0.5, 0.5) or smaller value, then the camera will move halfway to the target’s position each frame, resulting in a smooth and gradual movement.

Source

pub fn get_follow_ratio(&self) -> Vec2

Gets the ratio at which the camera should move to keep up with the target’s position. For example, set to Vec2(1.0, 1.0), then the camera will keep up to the target’s position right away. Set to Vec2(0.5, 0.5) or smaller value, then the camera will move halfway to the target’s position each frame, resulting in a smooth and gradual movement.

Source

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

Sets the offset at which the camera should follow the target.

Source

pub fn get_follow_offset(&self) -> Vec2

Gets the offset at which the camera should follow the target.

Source

pub fn set_follow_target(&mut self, val: &dyn INode)

Sets the game unit that the camera should track.

Source

pub fn get_follow_target(&self) -> Option<Node>

Gets the game unit that the camera should track.

Source

pub fn set_follow_target_null(&mut self)

Removes the target that the camera is following.

Source

pub fn new(name: &str) -> PlatformCamera

Creates a new instance of PlatformCamera.

§Arguments
  • name - An optional string that specifies the name of the new instance. Default is an empty string.
§Returns
  • A new PlatformCamera instance.

Trait Implementations§

Source§

impl Clone for PlatformCamera

Source§

fn clone(&self) -> PlatformCamera

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 PlatformCamera

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl ICamera for PlatformCamera

Source§

fn get_name(&self) -> String

Gets the name of the Camera.
Source§

impl IObject for PlatformCamera

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.