Hi, I have two spritesheets, and want to spawn them using a function.
I have a list with the images and use a for loop to spawn. And also have a tuple with two vector to use as a position.
I've tried to use a variable i to change the vector in translate:
translation: Vec3::new(pos.i.0, pos.i.1, pos.i.2),
and get this error.
no field i on type (({float}, {float}, {float}), ({float}, {float}, {float}))
fn spawn_bird(
mut commands: Commands,
asset_server: Res<AssetServer>,
mut texture_atlases: ResMut<Assets<TextureAtlas>>,){
let atlases = [ "pajaro.png", "pajaro_loco.png"];
let pos = ((0.,0.,0.) , (50.,0.,0.));
for texture in atlases {
let mut sprite = TextureAtlasSprite::new(0);
sprite.custom_size = Some(Vec2::splat(1.0));
let image = asset_server.load(texture);
let atlas = TextureAtlas::from_grid(image, Vec2::splat(32.0), 3, 1);
let atlas_handle = texture_atlases.add(atlas);
commands.spawn_bundle(SpriteSheetBundle{
texture_atlas:atlas_handle,
sprite: sprite,
transform: Transform {
translation: Vec3::new(pos.i.0, pos.i.1, pos.i.2),
scale: Vec3::new(SCALE,SCALE,SCALE),
..Default::default()
},
..Default::default()
})
.insert(AnimationTimer(Timer::from_seconds(0.2, true)));
}