[−][src]Struct specs_blit::Sprite
Specs component representing a sprite that can be drawn.
use blit::{BlitBuffer, Color}; use specs::prelude::*; use specs_blit::{load, Sprite}; const MASK_COLOR: u32 = 0xFF00FF; // Setup the specs world let mut world = World::new(); // Load the blit components into the world world.register::<Sprite>(); let sprite_ref = { // Create a sprite of 2 pixels let sprite = BlitBuffer::from_buffer(&[0, MASK_COLOR], 1, Color::from_u32(MASK_COLOR)); // Load the sprite and get a reference load(sprite)? }; // Create a new sprite entity in the ECS system world.create_entity() .with(Sprite::new(sprite_ref)) .build();
Methods
impl Sprite
[src]
pub fn new(index: SpriteRef) -> Self
[src]
Instantiate a new sprite from a loaded sprite index.
use blit::{BlitBuffer, Color}; use specs_blit::{load, Sprite}; const MASK_COLOR: u32 = 0xFF00FF; let sprite_ref = { // Create a sprite of 2 pixels let sprite = BlitBuffer::from_buffer(&[0, MASK_COLOR], 1, Color::from_u32(MASK_COLOR)); // Load the sprite and get a reference load(sprite)? }; // Create a specs sprite from the image let sprite = Sprite::new(sprite_ref);
pub fn set_pos(&mut self, x: i32, y: i32)
[src]
Set the pixel position of where the sprite needs to be rendered.
pub fn pos(&self) -> (i32, i32)
[src]
Get the pixel position as an (x, y) tuple of where the sprite will be rendered.
Trait Implementations
impl Component for Sprite
[src]
type Storage = VecStorage<Self>
Associated storage type for this component.
Auto Trait Implementations
impl RefUnwindSafe for Sprite
impl Send for Sprite
impl Sync for Sprite
impl Unpin for Sprite
impl UnwindSafe for Sprite
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Any for T where
T: Any,
T: Any,
fn get_type_id(&self) -> TypeId
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Event for T where
T: Send + Sync + 'static,
T: Send + Sync + 'static,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Resource for T where
T: Any + Send + Sync,
T: Any + Send + Sync,
impl<T> SetParameter for T
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
T: Parameter<Self>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,