more refactoring, compiles.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use crate::canvas::Drawable;
|
||||
use crate::canvas::{Drawable, CanvasTextureHandle, CanvasImageHandle};
|
||||
use std::sync::Arc;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -10,7 +10,7 @@ pub struct Sprite {
|
||||
color: (f32, f32, f32, f32),
|
||||
|
||||
textured: bool,
|
||||
texture_id: Option<Arc<u32>>,
|
||||
texture_handle: Option<Arc<CanvasTextureHandle>>,
|
||||
|
||||
}
|
||||
|
||||
@@ -20,7 +20,9 @@ impl Sprite {
|
||||
Sprite::new_with_color(position, size, (0.,0.,0.,0.))
|
||||
}
|
||||
|
||||
pub fn new_with_color(position: (f32, f32), size: (f32, f32), color: (f32, f32, f32, f32)) -> Sprite {
|
||||
pub fn new_with_color(position: (f32, f32),
|
||||
size: (f32, f32),
|
||||
color: (f32, f32, f32, f32)) -> Sprite {
|
||||
|
||||
let fsize = (size.0 as f32, size.1 as f32);
|
||||
|
||||
@@ -38,11 +40,11 @@ impl Sprite {
|
||||
size: size,
|
||||
color: color,
|
||||
textured: false,
|
||||
texture_id: None
|
||||
texture_handle: None
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_with_texture(position: (f32, f32), size: (f32, f32), texture_id: Arc<u32>) -> Sprite {
|
||||
pub fn new_with_texture(position: (f32, f32), size: (f32, f32), texture_handle: Arc<CanvasTextureHandle>) -> Sprite {
|
||||
|
||||
let fsize = (size.0 as f32, size.1 as f32);
|
||||
|
||||
@@ -59,7 +61,7 @@ impl Sprite {
|
||||
size: size,
|
||||
color: (0.0, 0.0, 0.0, 0.0),
|
||||
textured: false,
|
||||
texture_id: Some(texture_id)
|
||||
texture_handle: Some(texture_handle.clone())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,16 +78,16 @@ impl Drawable for Sprite {
|
||||
self.color.clone()
|
||||
}
|
||||
|
||||
fn get_texture_handle(&self) -> Option<Arc<u32>> {
|
||||
fn get_texture_handle(&self) -> Option<Arc<CanvasTextureHandle>> {
|
||||
match self.textured {
|
||||
true => {
|
||||
self.texture_id.clone()
|
||||
self.texture_handle.clone()
|
||||
},
|
||||
false => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn get_image_handle(&self) -> Option<Arc<u32>> {
|
||||
fn get_image_handle(&self) -> Option<Arc<CanvasImageHandle>> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user