I'm trying to make a Street Fighter-like game, and I want to have different background music depending on which character is in the world. Does anyone know how to do that?
thanks in advance :)
The greenfoot.Actor class does have an 'addedToWorld' method that is called for each actor object each time that it is added into any world. That would seem the appropriate place to place the code to change the music to what you want for each type actor. In order to stop the music that is currently playing, you must keep a reference to it (a field must be maintained to hold the GreenfootSound object). Then, that field must be accessible to the character classes.