Hi there I am a complete amateur working on a small project to learn Phaser. I followed a tutorial and managed to recreate a super basic game similar to Breakout and now I’m trying to see how I can change it. One thing I thought to do for fun is to make it so that multiple balls spawn at the beginning, and also make it so the sprites/textures/images (not sure correct term) of the bullets are randomized every time.
I was a bit ambitious when I started this side quest however and ended up getting over 30 textures to randomize as ball ‘types’ and now I’m not sure how to do it.
In my head the first challenge is that I need to pre-load 30+ textures and so far I’ve been doing a single “load” line per texture like this:
this.load.image('ball1', 'assets/skins/whiteball.png')
this.load.image('fireball', 'assets/skins/redball.png')
etc.
Doing 30 lines of this seems inefficient but perhaps its the best way as I didn’t find anything else I could do in my googling efforts.
After loading all the images I would then think I need to somehow group them for another function to pull from later on and randomize. But again after quite a bit of googling I am struggling for the answer to this. I don’t know if I need to somehow group the 30 ball textures during the load phase with something about the Loader, or the best method is to just do it manually such as:
balllist = this.physics.add.group()
balllist.add('ball1')
balllist.add('fireball')
etc.
Are there any tips on how to achieve the goal I have in mind? I feel that with all the examples and resources that I came across so in my searching that I can probably get something working if I do everything manually but at the same time I thought it would be a good opportunity to see how to solve these and then be able to use the solutions again in the future.
Thank you!