bevy_aseprite_ultra
bevy_aseprite_ultra copied to clipboard
Multiple sprites seem not to work.
I might just be too much of a noob with Bevy to understand what I'm doing wrong here, but the following only draws one sprite; all other sprites are just a single white pixel.
fn setup() {
let mut rng = rand::thread_rng();
for _ in 0..10 {
commands.spawn((
// . . .
AseSpriteAnimation {
animation: Animation::tag("scuttle"),
aseprite: asset_server.load("crab.aseprite"),
},
ManualTick,
));
}
}
fn move_crabs(
mut commands: Commands,
mut crab_query: Query<
(&mut Crab, &mut Position, &mut Direction, Entity),
With<AseSpriteAnimation>,
>,
time: Res<Time>,
) {
for (mut crab, mut pos, mut dir, entity) in crab_query.iter_mut() {
let current_time = time.elapsed().as_millis() as u64;
if current_time >= crab.next_walk_at {
crab.next_walk_at = current_time.wrapping_add(crab.walk_interval);
let (x_offset, y_offset) = dir.to_offset_with_scale(crab.walk_distance);
pos.x += x_offset;
pos.y += y_offset;
commands.trigger_targets(NextFrameEvent, entity);
}
}
}
Am I misunderstanding something about Bevy or misusing this library somehow?