[][src]Struct sfml::graphics::Sprite

pub struct Sprite<'s> { /* fields omitted */ }

Drawable representation of a texture

Sprite is a drawable type that allows to easily display a Texture (or a part of it) on a render target.

Methods

impl<'s> Sprite<'s>[src]

pub fn new() -> Sprite<'s>[src]

Create a new sprite

Return Some(Sprite) or None

pub fn with_texture(texture: &'s Texture) -> Sprite<'s>[src]

Create a new sprite with a texture

Return Some(Sprite) or None

pub fn set_texture(&mut self, texture: &'s Texture, reset_rect: bool)[src]

Change the source texture of a sprite

The texture argument refers to a texture that must exist as long as the sprite uses it. Indeed, the sprite doesn't store its own copy of the texture, but rather keeps a pointer to the one that you passed to this function. If the source texture is destroyed and the sprite tries to use it, the behaviour is undefined. If reset_rect is true, the texture_rect property of the sprite is automatically adjusted to the size of the new texture. If it is false, the texture rect is left unchanged.

Arguments

  • texture - New texture
  • reset_rect - Should the texture rect be reset to the size of the new texture?

pub fn disable_texture(&mut self)[src]

Disable Texturing

Disable the current texture and reset the texture rect

pub fn set_color(&mut self, color: Color)[src]

Set the global color of a sprite

This color is modulated (multiplied) with the sprite's texture. It can be used to colorize the sprite, or change its global opacity. By default, the sprite's color is opaque white.

Arguments

  • color - New color of the sprite

pub fn texture(&self) -> Option<&'s Texture>[src]

Get the source texture of a sprite

If the sprite has no source texture, None is returned. You can't modify the texture when you retrieve it with this function.

Return an Option to the sprite's texture

pub fn color(&self) -> Color[src]

Get the global color of a sprite

Return the global color of the sprite

pub fn local_bounds(&self) -> FloatRect[src]

Get the local bounding rectangle of a sprite

The returned rectangle is in local coordinates, which means that it ignores the transformations (translation, rotation, scale, ...) that are applied to the entity. In other words, this function returns the bounds of the entity in the entity's coordinate system.

Return the local bounding rectangle of the entity

pub fn global_bounds(&self) -> FloatRect[src]

Get the global bounding rectangle of a sprite

The returned rectangle is in global coordinates, which means that it takes in account the transformations (translation, rotation, scale, ...) that are applied to the entity. In other words, this function returns the bounds of the sprite in the global 2D world's coordinate system.

Return the global bounding rectangle of the entity

pub fn texture_rect(&self) -> IntRect[src]

Get the sub-rectangle of the texture displayed by a sprite

Return the texture rectangle of the sprite

pub fn set_texture_rect(&mut self, rect: &IntRect)[src]

Set the sub-rectangle of the texture that a sprite will display

The texture rect is useful when you don't want to display the whole texture, but rather a part of it. By default, the texture rect covers the entire texture.

Arguments

  • rectangle - Rectangle defining the region of the texture to display

Trait Implementations

impl<'s> Drawable for Sprite<'s>[src]

impl<'s> Transformable for Sprite<'s>[src]

impl<'s> Drop for Sprite<'s>[src]

impl<'s> Clone for Sprite<'s>[src]

fn clone(&self) -> Sprite<'s>[src]

Return a new Sprite or panic! if there is not enough memory

impl<'s> Default for Sprite<'s>[src]

impl<'s> Debug for Sprite<'s>[src]

Auto Trait Implementations

impl<'s> !Send for Sprite<'s>

impl<'s> !Sync for Sprite<'s>

impl<'s> Unpin for Sprite<'s>

impl<'s> UnwindSafe for Sprite<'s>

impl<'s> RefUnwindSafe for Sprite<'s>

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]