Struct playdate_rs::sprite::PlaydateSprite
source · pub struct PlaydateSprite { /* private fields */ }Implementations§
source§impl PlaydateSprite
impl PlaydateSprite
sourcepub fn set_always_redraw(&self, flag: bool)
pub fn set_always_redraw(&self, flag: bool)
When flag is set to 1, the given sprite will always redraw.
sourcepub fn add_dirty_rect(&self, dirty_rect: SideOffsets2D<i32>)
pub fn add_dirty_rect(&self, dirty_rect: SideOffsets2D<i32>)
Marks the given dirtyRect (in screen coordinates) as needing a redraw. Graphics drawing functions now call this automatically, adding their drawn areas to the sprite’s dirty list, so there’s usually no need to call this manually.
sourcepub fn draw_sprites(&self)
pub fn draw_sprites(&self)
Draws every sprite in the display list.
sourcepub fn update_and_draw_sprites(&self)
pub fn update_and_draw_sprites(&self)
Updates and draws every sprite in the display list.
sourcepub fn new_sprite(&self) -> Sprite
pub fn new_sprite(&self) -> Sprite
Allocates and returns a new LCDSprite.
sourcepub fn add_sprite(&self, sprite: impl AsRef<Sprite>)
pub fn add_sprite(&self, sprite: impl AsRef<Sprite>)
Adds the given sprite to the display list, so that it is drawn in the current scene.
sourcepub fn remove_sprite(&self, sprite: impl AsRef<Sprite>)
pub fn remove_sprite(&self, sprite: impl AsRef<Sprite>)
Removes the given sprite from the display list.
sourcepub fn remove_sprites(&self, sprites: &[&Sprite])
pub fn remove_sprites(&self, sprites: &[&Sprite])
Removes the given count sized array of sprites from the display list.
sourcepub fn remove_all_sprites(&self)
pub fn remove_all_sprites(&self)
Removes all sprites from the display list.
sourcepub fn get_sprite_count(&self) -> usize
pub fn get_sprite_count(&self) -> usize
Returns the total number of sprites in the display list.
sourcepub fn set_clip_rects_in_range(
&self,
clip_rect: SideOffsets2D<i32>,
start_z: i32,
end_z: i32
)
pub fn set_clip_rects_in_range( &self, clip_rect: SideOffsets2D<i32>, start_z: i32, end_z: i32 )
Sets the clipping rectangle for all sprites with a Z index within startZ and endZ inclusive.
sourcepub fn clear_clip_rects_in_range(&self, start_z: i32, end_z: i32)
pub fn clear_clip_rects_in_range(&self, start_z: i32, end_z: i32)
Clears the clipping rectangle for all sprites with a Z index within startZ and endZ inclusive.
sourcepub fn reset_collision_world(&self)
pub fn reset_collision_world(&self)
Frees and reallocates internal collision data, resetting everything to its default state.
sourcepub fn check_collisions(
&self,
sprite: impl AsRef<Sprite>,
goal_x: f32,
goal_y: f32
) -> Vec<SpriteCollisionInfo<'_>>
pub fn check_collisions( &self, sprite: impl AsRef<Sprite>, goal_x: f32, goal_y: f32 ) -> Vec<SpriteCollisionInfo<'_>>
Returns the same values as playdate->sprite->moveWithCollisions() but does not actually move the sprite.
sourcepub fn move_with_collisions(
&self,
sprite: impl AsRef<Sprite>,
goal_x: f32,
goal_y: f32
) -> Vec<SpriteCollisionInfo<'_>>
pub fn move_with_collisions( &self, sprite: impl AsRef<Sprite>, goal_x: f32, goal_y: f32 ) -> Vec<SpriteCollisionInfo<'_>>
Moves the given sprite towards goalX, goalY taking collisions into account and returns an array of SpriteCollisionInfo. len is set to the size of the array and actualX, actualY are set to the sprite’s position after collisions. If no collisions occurred, this will be the same as goalX, goalY.
pub fn query_sprites_at_point(&self, x: f32, y: f32) -> Vec<Ref<'_, Sprite>>
pub fn query_sprites_in_rect( &self, x: f32, y: f32, width: f32, height: f32 ) -> Vec<Ref<'_, Sprite>>
pub fn query_sprites_along_line( &self, x1: f32, y1: f32, x2: f32, y2: f32 ) -> Vec<Ref<'_, Sprite>>
pub fn query_sprite_info_along_line( &self, x1: f32, y1: f32, x2: f32, y2: f32 ) -> Vec<SpriteQueryInfo<'_>>
sourcepub fn overlapping_sprites(
&self,
sprite: impl AsRef<Sprite>
) -> Vec<Ref<'_, Sprite>>
pub fn overlapping_sprites( &self, sprite: impl AsRef<Sprite> ) -> Vec<Ref<'_, Sprite>>
Returns an array of sprites that have collide rects that are currently overlapping the given sprite’s collide rect.
sourcepub fn all_overlapping_sprites(&self) -> Vec<Ref<'_, Sprite>>
pub fn all_overlapping_sprites(&self) -> Vec<Ref<'_, Sprite>>
Returns an array of all sprites that have collide rects that are currently overlapping. Each consecutive pair of sprites is overlapping (eg. 0 & 1 overlap, 2 & 3 overlap, etc).