1

I have been trying to make an animation work with spritewidget, but I can't seem to see how they make this work.

I have the following

await _fireworksImageMap.load(<String>[
                          'assets/sprites/fireworks/fireworks_sprite_sheet_0.png',
                          'assets/sprites/fireworks/fireworks_sprite_sheet_1.png',
                          'assets/sprites/fireworks/fireworks_sprite_sheet_2.png',
                          'assets/sprites/fireworks/fireworks_sprite_sheet_3.png',
                        ]);

  // Load sprite sheets
 String json = await _bundle.loadString('assets/sprites/fireworks/fireworks_sprite_sheet_0.json');
                        fireworksSpriteSheet = new SpriteSheet(_fireworksImageMap['assets/sprites/fireworks/fireworks_sprite_sheet_0.png'], json);

This is basically what I have, I do however have 3 more json sheets for that animation, png 0 to 3 are all part of a single animation. I know I have to fit this is in a spriteWidget(). But I have no idea how to get this to return an animation and really not with several spritesheets.

I hope someone could help me with some directions or a sample. There is hardly any information about spritewidget, except for the samples on GitHub that hardly gives any information.

carlosx2
  • 1,672
  • 16
  • 23
  • It took me a while to find out about this too. There's an example in https://github.com/spritewidget/spaceblast/blob/master/lib/widgets.dart. Search for config.texture.drawTexture you'll see that you can draw to a canvas in the paint method. – user2740650 Jan 13 '23 at 01:09
  • Related question: https://stackoverflow.com/questions/72512596/looping-through-images-using-spritewidget – user2740650 Jan 13 '23 at 01:10

0 Answers0