I'm trying to use an array of sprites as an inventory system, but to do so I need three methods to use with the array.
- one that puts sprites in the array
- one that shows if a certain sprite is in the array or not
- one that takes the sprites out of the array
I have a solution for the second one, and I've tried a few times to use add and remove methods for the other two, but I don't know exactly how to call those methods correctly, as the ways I tried just got me error messages. As I have found the online documentation too confusing for me, can please tell me of the methods I'm looking for?
Also, I've tried creating the array in 2 formats:
let inventory = [];
and
let inventory = [null, null, null, null, null, null, null, null, null, null];
Do the methods I'm looking for change depending on which one I use.
If it helps, I'm using Phaser 3 in VSCode, employing arcade physics.