Skip to main content

Assets

Struct Assets 

Source
pub struct Assets { /* private fields */ }
Expand description

Gestor de assets (texturas) Nota: La carga de texturas se hace desde RyDit usando raylib directamente

Implementations§

Source§

impl Assets

Source

pub fn new() -> Self

Source

pub fn load_texture_from_path(path: &str) -> Result<Texture2D, String>

Cargar textura desde archivo (función estática usando FFI)

Source

pub fn insert_texture(&mut self, id: String, texture: Texture2D)

Insertar textura cargada desde RyDit

Source

pub fn get_texture(&self, id: &str) -> Option<&Texture2D>

Obtener textura por ID

Source

pub fn unload_texture(&mut self, id: &str) -> bool

Descargar textura y liberar memoria

Source

pub fn draw_texture( &self, d: &mut RaylibDrawHandle<'_>, id: &str, x: f32, y: f32, _w: f32, _h: f32, color: Color, )

Dibujar textura en pantalla

§Arguments (en orden):
  1. d - Draw handle de raylib
  2. id - ID del sprite cargado 3-4. x, y - Posición en pantalla 5-6. _w, _h - Dimensiones (actualmente no usadas)
  3. color - Color de tinte
§Nota

Los parámetros _w y _h son reservados para futura implementación de escalado.

Source

pub fn draw_texture_scaled( &self, d: &mut RaylibDrawHandle<'_>, id: &str, x: f32, y: f32, scale: f32, color: Color, )

Dibujar textura escalada

Source

pub fn draw_texture_ex_by_id( &self, d: &mut RaylibDrawHandle<'_>, id: &str, x: f32, y: f32, scale: f32, rotation: f32, color: ColorRydit, )

Dibujar textura con rotación y escala (para RenderQueue)

Source

pub fn draw_texture_rec( &self, d: &mut RaylibDrawHandle<'_>, id: &str, source: Rectangle, dest: Rectangle, color: Color, )

Dibujar rectángulo de textura (para tilesets)

Source

pub fn has_texture(&self, id: &str) -> bool

Verificar si existe una textura

Source

pub fn texture_count(&self) -> usize

Cantidad de texturas cargadas

Source

pub fn clear(&mut self)

Limpiar todas las texturas

Source

pub fn load_texture_sdl2<'a>( path: &str, texture_creator: &'a TextureCreator<WindowContext>, ) -> Result<Texture<'a>, String>

Cargar textura SDL2 desde archivo (usando FFI nativo) Retorna la textura que debe ser gestionada por el caller Nota: El lifetime de la textura está ligado al texture_creator

Source

pub fn draw_texture_sdl2( canvas: &mut Canvas<Window>, texture: &Texture<'_>, x: i32, y: i32, width: u32, height: u32, ) -> Result<(), String>

Dibujar textura SDL2 directamente (sin gestor de assets)

Trait Implementations§

Source§

impl Default for Assets

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.