For an example, I will use libgdx (game engine) but this is a question about how java works that i didn't find.
This is the soundControler class:
private final Sound s_0 = Gdx.audio.newSound(Gdx.files.internal("a.mp3"));;
private final Sound s_1 = Gdx.audio.newSound(Gdx.files.internal("a.wav"));
//lot of more variables
public void shoot(short sound){
if(SOUND_ENDABLED) {
switch (sound) {
case 0:
s_0.play();
break;
case 1:
s_1.play();
break;
}
}
}
So this is basically a library of sounds loaded in memory, which the program will be using constantly.
Another example:
Let's say we have an Animator
class that will have a LOT of methods for every animation in the game.
Is this a good practice? Or will I be making a new copy of all the sounds and methods in memory every time I pass the soundControler
as a parameter?