pub enum Size {
S8x8 = 0,
S16x16 = 1,
S32x32 = 2,
S64x64 = 3,
S16x8 = 4,
S32x8 = 5,
S32x16 = 6,
S64x32 = 7,
S8x16 = 8,
S8x32 = 9,
S16x32 = 10,
S32x64 = 11,
}
Expand description
The sizes of sprite supported by the GBA.
Variants§
S8x8 = 0
S16x16 = 1
S32x32 = 2
S64x64 = 3
S16x8 = 4
S32x8 = 5
S32x16 = 6
S64x32 = 7
S8x16 = 8
S8x32 = 9
S16x32 = 10
S32x64 = 11
Implementations§
source§impl Size
impl Size
sourcepub const fn from_width_height(width: usize, height: usize) -> Self
pub const fn from_width_height(width: usize, height: usize) -> Self
Creates a size from width and height in pixels, panics if the width and height is not representable by GBA sprites.
sourcepub const fn to_width_height(self) -> (usize, usize)
pub const fn to_width_height(self) -> (usize, usize)
Returns the width and height of the size in pixels.
Examples found in repository?
examples/sprites.rs (line 86)
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
fn all_tags(gfx: &OamManaged) {
let mut input = agb::input::ButtonController::new();
let mut objs = Vec::new();
for (i, v) in TAG_MAP.values().enumerate() {
let x = (i % 7) as i32;
let y = (i / 7) as i32;
let sprite = v.sprite(0);
let (size_x, size_y) = sprite.size().to_width_height();
let (size_x, size_y) = (size_x as i32, size_y as i32);
let mut obj = gfx.object_sprite(sprite);
obj.show();
obj.set_position((x * 32 + 16 - size_x / 2, y * 32 + 16 - size_y / 2));
objs.push((obj, v));
}
let mut count = 0;
let mut image = 0;
let vblank = agb::interrupt::VBlank::get();
loop {
vblank.wait_for_vblank();
input.update();
if input.is_just_pressed(agb::input::Button::A) {
break;
}
count += 1;
if count % 5 == 0 {
image += 1;
for (obj, tag) in objs.iter_mut() {
obj.set_sprite(gfx.sprite(tag.animation_sprite(image)));
}
gfx.commit();
}
}
}
sourcepub const fn to_tiles_width_height(self) -> (usize, usize)
pub const fn to_tiles_width_height(self) -> (usize, usize)
Returns the width and height of the size in pixels.
Trait Implementations§
impl Copy for Size
impl Eq for Size
impl StructuralPartialEq for Size
Auto Trait Implementations§
impl Freeze for Size
impl RefUnwindSafe for Size
impl Send for Size
impl Sync for Size
impl Unpin for Size
impl UnwindSafe for Size
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
Mutably borrows from an owned value. Read more