This site requires JavaScript, please enable it in your browser!
Greenfoot back
fauxcaleb
fauxcaleb wrote ...

2015/6/8

How to play music for certain actors

fauxcaleb fauxcaleb

2015/6/8

#
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 :)
azazeel azazeel

2015/6/8

#
read this first oke let me try my best, use GreenfootSound as background and just change the value depend on character
danpost danpost

2015/6/8

#
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.
plant plant

2015/6/10

#
Try typing Greenfoot.<space> You will get a lot of premade methods. There may be a stop sound method in there.
You need to login to post a reply.