pub struct Handle<const FOD: bool, Sp, T, H>(/* private fields */)
where
T: Sized,
Sp: TypedSprite,
H: SpriteDraw;Implementations§
Source§impl<const FOD: bool, Sp, T, H> Handle<FOD, Sp, T, H>where
T: AsRef<Sp>,
Sp: TypedSprite,
H: SpriteDraw,
impl<const FOD: bool, Sp, T, H> Handle<FOD, Sp, T, H>where
T: AsRef<Sp>,
Sp: TypedSprite,
H: SpriteDraw,
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
- Unregister inner callback for sprite
- Unwrap, return the underlying sprite
- Remove the collision response handler
Source§impl<UD, Api, const FOD: bool, H, H0> Handle<FOD, Sprite<UD, Api, FOD>, Handle<FOD, Sprite<UD, Api, FOD>, H0>, H>
impl<UD, Api, const FOD: bool, H, H0> Handle<FOD, Sprite<UD, Api, FOD>, Handle<FOD, Sprite<UD, Api, FOD>, H0>, H>
Sourcepub fn into_update_handler<T: SpriteUpdate<Userdata = UD>>(
self,
) -> Handle<FOD, Sprite<UD, Api, FOD>, Self, T>where
T::Api: Default,
pub fn into_update_handler<T: SpriteUpdate<Userdata = UD>>(
self,
) -> Handle<FOD, Sprite<UD, Api, FOD>, Self, T>where
T::Api: Default,
Sets the update function for the this sprite.
Source§impl<UD, Api, const FOD: bool, H, H0> Handle<FOD, Sprite<UD, Api, FOD>, Handle<FOD, Sprite<UD, Api, FOD>, H0>, H>
impl<UD, Api, const FOD: bool, H, H0> Handle<FOD, Sprite<UD, Api, FOD>, Handle<FOD, Sprite<UD, Api, FOD>, H0>, H>
Sourcepub fn into_collision_response_handler<T: SpriteCollisionResponse<Userdata = UD>>(
self,
) -> Handle<FOD, Sprite<UD, Api, FOD>, Self, T>where
T::Api: Default,
pub fn into_collision_response_handler<T: SpriteCollisionResponse<Userdata = UD>>(
self,
) -> Handle<FOD, Sprite<UD, Api, FOD>, Self, T>where
T::Api: Default,
Sets the collision response function for the this sprite.
Methods from Deref<Target = Sprite<Sp::Userdata, Sp::Api, FOD>>§
Sourcepub fn add(&self)
pub fn add(&self)
Adds the this sprite to the display list, so that it is drawn in the current scene.
Equivalent to sys::ffi::playdate_sprite::addSprite
Sourcepub fn remove(&self)
pub fn remove(&self)
Removes the this sprite from the display list.
Equivalent to sys::ffi::playdate_sprite::removeSprite
Sourcepub fn set_bounds(&self, bounds: PDRect)
pub fn set_bounds(&self, bounds: PDRect)
Sets the bounds of the sprite with bounds.
Equivalent to sys::ffi::playdate_sprite::setBounds
Sourcepub fn bounds(&self) -> PDRect
pub fn bounds(&self) -> PDRect
Returns the bounds of the sprite.
Equivalent to sys::ffi::playdate_sprite::getBounds
Sourcepub fn move_to(&self, x: c_float, y: c_float)
pub fn move_to(&self, x: c_float, y: c_float)
Moves the sprite to x, y and resets its bounds based on the bitmap dimensions and center.
Equivalent to sys::ffi::playdate_sprite::moveTo
Sourcepub fn move_by(&self, dx: c_float, dy: c_float)
pub fn move_by(&self, dx: c_float, dy: c_float)
Moves the sprite to by offsetting its current position by dx, dy.
Equivalent to sys::ffi::playdate_sprite::moveBy
Sourcepub fn set_image(&self, image: impl AnyBitmap, flip: BitmapFlip)
pub fn set_image(&self, image: impl AnyBitmap, flip: BitmapFlip)
Sets the sprite’s image to the given bitmap.
⚠️ Caution: Using with draw function, call this method before set callback. Setting image after setting draw callback is mostly crashes with SIGBUS.
See also set_opaque.
Equivalent to sys::ffi::playdate_sprite::setImage
Sourcepub fn image<'t>(&'t self) -> Option<BitmapRef<'t>>
pub fn image<'t>(&'t self) -> Option<BitmapRef<'t>>
Returns the bitmap currently assigned to the given sprite.
Equivalent to sys::ffi::playdate_sprite::getImage
Sourcepub fn set_size(&self, width: c_float, height: c_float)
pub fn set_size(&self, width: c_float, height: c_float)
Sets the size.
The size is used to set the sprite’s bounds when calling move_to.
Equivalent to sys::ffi::playdate_sprite::setSize
Sourcepub fn set_z_index(&self, z_index: i16)
pub fn set_z_index(&self, z_index: i16)
Sets the Z order of the sprite. Higher Z sprites are drawn on top of those with lower Z order.
Equivalent to sys::ffi::playdate_sprite::setZIndex
Sourcepub fn z_index(&self) -> i16
pub fn z_index(&self) -> i16
Returns the Z index of the sprite.
Equivalent to sys::ffi::playdate_sprite::getZIndex
Sourcepub fn set_draw_mode(&self, mode: BitmapDrawMode)
pub fn set_draw_mode(&self, mode: BitmapDrawMode)
Sets the mode for drawing the sprite’s bitmap.
Equivalent to sys::ffi::playdate_sprite::setDrawMode
Sourcepub fn set_image_flip(&self, flip: BitmapFlip)
pub fn set_image_flip(&self, flip: BitmapFlip)
Flips the sprite’s bitmap.
Equivalent to sys::ffi::playdate_sprite::setImageFlip
Sourcepub fn image_flip(&self) -> BitmapFlip
pub fn image_flip(&self) -> BitmapFlip
Returns the flip setting of the sprite’s bitmap.
Equivalent to sys::ffi::playdate_sprite::getImageFlip
Sourcepub fn set_stencil(&self, stencil: impl AnyBitmap)
pub fn set_stencil(&self, stencil: impl AnyBitmap)
Specifies a stencil image to be set on the frame buffer before the sprite is drawn.
Equivalent to sys::ffi::playdate_sprite::setStencil
Sourcepub fn set_clip_rect(&self, clip: LCDRect)
pub fn set_clip_rect(&self, clip: LCDRect)
Sets the clipping rectangle for sprite drawing.
Equivalent to sys::ffi::playdate_sprite::setClipRect
Sourcepub fn clear_clip_rect(&self)
pub fn clear_clip_rect(&self)
Clears the sprite’s clipping rectangle.
Equivalent to sys::ffi::playdate_sprite::clearClipRect
Sourcepub fn set_updates_enabled(&self, value: bool)
pub fn set_updates_enabled(&self, value: bool)
Set the updates_enabled flag of the sprite
(determines whether the sprite has its update function called).
Equivalent to sys::ffi::playdate_sprite::setUpdatesEnabled
Sourcepub fn updates_enabled(&self) -> bool
pub fn updates_enabled(&self) -> bool
Get the updates_enabled flag of the sprite.
Equivalent to sys::ffi::playdate_sprite::updatesEnabled
Sourcepub fn set_collisions_enabled(&self, value: bool)
pub fn set_collisions_enabled(&self, value: bool)
Set the collisions_enabled flag of the sprite
(along with the collide_rect, this determines whether the sprite participates in collisions).
Set to true by default.
See also collide_rect,
set_collide_rect,
clear_collide_rect.
Equivalent to sys::ffi::playdate_sprite::setCollisionsEnabled
Sourcepub fn collisions_enabled(&self) -> bool
pub fn collisions_enabled(&self) -> bool
Get the collisions_enabled flag of the sprite.
Equivalent to sys::ffi::playdate_sprite::collisionsEnabled
Sourcepub fn set_visible(&self, value: bool)
pub fn set_visible(&self, value: bool)
Set the visible flag of the given sprite (determines whether the sprite has its draw function called).
Equivalent to sys::ffi::playdate_sprite::setVisible
Sourcepub fn is_visible(&self) -> bool
pub fn is_visible(&self) -> bool
Get the visible flag of the sprite.
Equivalent to sys::ffi::playdate_sprite::isVisible
Sourcepub fn set_opaque(&self, value: bool)
pub fn set_opaque(&self, value: bool)
Marking a sprite opaque tells the sprite system that it doesn’t need to draw anything underneath the sprite, since it will be overdrawn anyway.
If you set an image without a mask/alpha channel on the sprite, it automatically sets the opaque flag.
Equivalent to sys::ffi::playdate_sprite::setOpaque
Sourcepub fn mark_dirty(&self)
pub fn mark_dirty(&self)
Forces the sprite to redraw.
Equivalent to sys::ffi::playdate_sprite::markDirty
Sourcepub fn set_tag(&self, tag: u8)
pub fn set_tag(&self, tag: u8)
Sets the tag of the sprite.
This can be useful for identifying sprites or types of sprites when using the collision API.
Equivalent to sys::ffi::playdate_sprite::setTag
Sourcepub fn tag(&self) -> u8
pub fn tag(&self) -> u8
Returns the tag of the given sprite.
Equivalent to sys::ffi::playdate_sprite::getTag
Sourcepub fn set_ignores_draw_offset(&self, value: bool)
pub fn set_ignores_draw_offset(&self, value: bool)
When flag is set to true,
the sprite will draw in screen coordinates,
ignoring the currently-set draw_offset.
This only affects drawing, and should not be used on sprites being used for collisions, which will still happen in world-space.
See also gfx::set_draw_offset.
Equivalent to sys::ffi::playdate_sprite::setIgnoresDrawOffset
Sourcepub fn position(&self) -> (c_float, c_float)
pub fn position(&self) -> (c_float, c_float)
Sets x and y to the current position of sprite.
Equivalent to get_position_to and sys::ffi::playdate_sprite::getPosition
Sourcepub fn position_to(&self, x: &mut c_float, y: &mut c_float)
pub fn position_to(&self, x: &mut c_float, y: &mut c_float)
Sets x and y to the current position of sprite.
Equivalent to sys::ffi::playdate_sprite::getPosition
Sourcepub fn set_collide_rect(&self, collide: PDRect)
pub fn set_collide_rect(&self, collide: PDRect)
Marks the area of the sprite, relative to its bounds, to be checked for collisions with other sprites’ collide rects.
Equivalent to sys::ffi::playdate_sprite::setCollideRect
Sourcepub fn collide_rect(&self) -> PDRect
pub fn collide_rect(&self) -> PDRect
Returns the sprite’s collide rect.
Equivalent to sys::ffi::playdate_sprite::getCollideRect
Sourcepub fn clear_collide_rect(&self)
pub fn clear_collide_rect(&self)
Clears the sprite’s collide rect.
Equivalent to sys::ffi::playdate_sprite::clearCollideRect
Sourcepub fn check_collisions(
&self,
goal_x: c_float,
goal_y: c_float,
actual_x: &mut c_float,
actual_y: &mut c_float,
) -> Option<Arr<'_, SpriteCollisionInfo>>
pub fn check_collisions( &self, goal_x: c_float, goal_y: c_float, actual_x: &mut c_float, actual_y: &mut c_float, ) -> Option<Arr<'_, SpriteCollisionInfo>>
Returns the same values as [move_with_collisions] but does not actually move the sprite.
Equivalent to sys::ffi::playdate_sprite::checkCollisions
Sourcepub fn move_with_collisions<'t>(
&'t self,
goal_x: c_float,
goal_y: c_float,
actual_x: &mut c_float,
actual_y: &mut c_float,
) -> Option<Arr<'t, SpriteCollisionInfo>>
pub fn move_with_collisions<'t>( &'t self, goal_x: c_float, goal_y: c_float, actual_x: &mut c_float, actual_y: &mut c_float, ) -> Option<Arr<'t, SpriteCollisionInfo>>
Moves the sprite towards goal_x, goal_y taking collisions into account
and returns a slice of SpriteCollisionInfo.
actual_x, actual_y are set to the sprite’s position after collisions.
If no collisions occurred, this will be the same as goal_x, goal_y.
Resulting slice with entire content can be freely dropped.
Equivalent to sys::ffi::playdate_sprite::moveWithCollisions
Sourcepub fn overlapping_sprites(&self) -> Option<Arr<'_, SpriteRef>>
pub fn overlapping_sprites(&self) -> Option<Arr<'_, SpriteRef>>
Returns an slice of sprites that have collide rects that are currently overlapping the given sprite’s collide rect.
Equivalent to sys::ffi::playdate_sprite::overlappingSprites
Sourcepub fn set_stencil_pattern(&self, pattern: &mut [u8; 8])
pub fn set_stencil_pattern(&self, pattern: &mut [u8; 8])
Sets the sprite’s stencil to the given pattern.
Equivalent to sys::ffi::playdate_sprite::setStencilPattern
Sourcepub fn set_stencil_image(&self, stencil: impl AnyBitmap, tile: bool)
pub fn set_stencil_image(&self, stencil: impl AnyBitmap, tile: bool)
Specifies a stencil image to be set on the frame buffer before the sprite is drawn.
If tile is set, the stencil will be tiled.
Tiled stencils must have width evenly divisible by 32.
Equivalent to sys::ffi::playdate_sprite::setStencilImage
Sourcepub fn clear_stencil(&self)
pub fn clear_stencil(&self)
Clears the sprite’s stencil.
Equivalent to sys::ffi::playdate_sprite::clearStencil
Sourcepub fn set_center(&self, x: c_float, y: c_float)
pub fn set_center(&self, x: c_float, y: c_float)
Sets the sprite’s drawing center as a fraction (ranging from 0.0 to 1.0) of the height and width.
Default is 0.5, 0.5 (the center of the sprite).
This means that when you call Sprite::move_to(x, y),
the center of your sprite will be positioned at x, y.
If you want x and y to represent the upper left corner of your sprite, specify the center as 0, 0.
Equivalent to sys::ffi::playdate_sprite::setCenter.
Sourcepub fn center(&self) -> (c_float, c_float)
pub fn center(&self) -> (c_float, c_float)
Returns the sprite’s drawing center as a fraction (ranging from 0.0 to 1.0) of the height and width.
Equivalent to sys::ffi::playdate_sprite::getCenter.
Sourcepub fn set_userdata(&self, data: Userdata)
pub fn set_userdata(&self, data: Userdata)
Sets custom data to the sprite.
Used for associating the sprite with other data.
Equivalent to sys::ffi::playdate_sprite::setUserdata
Sourcepub fn userdata(&self) -> Option<&mut Userdata>
pub fn userdata(&self) -> Option<&mut Userdata>
Gets the mutable_ reference to sprite’s userdata.
Used for associating the sprite with other data.
Equivalent to sys::ffi::playdate_sprite::getUserdata
Trait Implementations§
Source§impl<const FOD: bool, Sp, T, H> AsRef<Sprite<<Sp as TypedSprite>::Userdata, <Sp as SpriteApi>::Api, FOD>> for Handle<FOD, Sp, T, H>
impl<const FOD: bool, Sp, T, H> AsRef<Sprite<<Sp as TypedSprite>::Userdata, <Sp as SpriteApi>::Api, FOD>> for Handle<FOD, Sp, T, H>
impl<const FOD: bool, Sp, T, H> AnySprite for Handle<FOD, Sp, T, H>
Auto Trait Implementations§
impl<const FOD: bool, Sp, T, H> Freeze for Handle<FOD, Sp, T, H>where
T: Freeze,
impl<const FOD: bool, Sp, T, H> RefUnwindSafe for Handle<FOD, Sp, T, H>where
T: RefUnwindSafe,
Sp: RefUnwindSafe,
H: RefUnwindSafe,
impl<const FOD: bool, Sp, T, H> Send for Handle<FOD, Sp, T, H>where
T: Send,
Sp: Send,
H: Send,
impl<const FOD: bool, Sp, T, H> Sync for Handle<FOD, Sp, T, H>where
T: Sync,
Sp: Sync,
H: Sync,
impl<const FOD: bool, Sp, T, H> Unpin for Handle<FOD, Sp, T, H>where
T: Unpin,
Sp: Unpin,
H: Unpin,
impl<const FOD: bool, Sp, T, H> UnwindSafe for Handle<FOD, Sp, T, H>where
T: UnwindSafe,
Sp: UnwindSafe,
H: UnwindSafe,
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T, U> Into<U> for Twhere
U: From<T>,
impl<T, U> Into<U> for Twhere
U: From<T>,
§impl<P, T> Receiver for Pwhere
P: Deref<Target = T> + ?Sized,
T: ?Sized,
impl<P, T> Receiver for Pwhere
P: Deref<Target = T> + ?Sized,
T: ?Sized,
§impl<T, U> TryFrom<U> for Twhere
U: Into<T>,
impl<T, U> TryFrom<U> for Twhere
U: Into<T>,
§impl<T, U> TryInto<U> for Twhere
U: TryFrom<T>,
impl<T, U> TryInto<U> for Twhere
U: TryFrom<T>,
impl<T> AnyFile for Twhere
T: AsRaw<Type = c_void>,
Layout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.