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
impl PlatformCamera
Sourcepub fn set_position(&mut self, val: &Vec2)
pub fn set_position(&mut self, val: &Vec2)
Sets The camera’s position.
Sourcepub fn get_position(&self) -> Vec2
pub fn get_position(&self) -> Vec2
Gets The camera’s position.
Sourcepub fn set_rotation(&mut self, val: f32)
pub fn set_rotation(&mut self, val: f32)
Sets The camera’s rotation in degrees.
Sourcepub fn get_rotation(&self) -> f32
pub fn get_rotation(&self) -> f32
Gets The camera’s rotation in degrees.
Sourcepub fn set_zoom(&mut self, val: f32)
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.
Sourcepub fn get_zoom(&self) -> f32
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.
Sourcepub fn set_boundary(&mut self, val: &Rect)
pub fn set_boundary(&mut self, val: &Rect)
Sets The rectangular area within which the camera is allowed to view.
Sourcepub fn get_boundary(&self) -> Rect
pub fn get_boundary(&self) -> Rect
Gets The rectangular area within which the camera is allowed to view.
Sourcepub fn set_follow_ratio(&mut self, val: &Vec2)
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.
Sourcepub fn get_follow_ratio(&self) -> Vec2
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.
Sourcepub fn set_follow_offset(&mut self, val: &Vec2)
pub fn set_follow_offset(&mut self, val: &Vec2)
Sets the offset at which the camera should follow the target.
Sourcepub fn get_follow_offset(&self) -> Vec2
pub fn get_follow_offset(&self) -> Vec2
Gets the offset at which the camera should follow the target.
Sourcepub fn set_follow_target(&mut self, val: &dyn INode)
pub fn set_follow_target(&mut self, val: &dyn INode)
Sets the game unit that the camera should track.
Sourcepub fn get_follow_target(&self) -> Option<Node>
pub fn get_follow_target(&self) -> Option<Node>
Gets the game unit that the camera should track.
Sourcepub fn set_follow_target_null(&mut self)
pub fn set_follow_target_null(&mut self)
Removes the target that the camera is following.
Trait Implementations§
Source§impl Clone for PlatformCamera
impl Clone for PlatformCamera
Source§fn clone(&self) -> PlatformCamera
fn clone(&self) -> PlatformCamera
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more