Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by nightbyter

Hello to all,
i have created a sub class to display an Intro-Slideshow with music before the game starts.
The idea was to display some pictures with music in the background until the user hits the SPACE-KEY. After this, i want to bail out to the StartScreen with ig.system.setGame(StartScreen)

It works nice but i cant to stop the music.
When i call setGame the music player forever, if i take this line out, the music stops.

// New Screen class for Intro story
IntroAni = ig.Game.extend({
	
    instructText: new ig.Font( 'media/2Comic-Font_Meili.font.png' ),
    Intro_bkg01: new ig.Image('media/intro/intro_01.png'),
    Intro_Image01: new ig.Image('media/intro/intro_01_2.png'),
    Intro_bkg02: new ig.Image('media/intro/intro_bkg2.png'),
    Intro_Image02: new ig.Image('media/intro/intro_02.png'),
    Intro_bkg03: new ig.Image('media/intro/intro_03.png'),
    displayTime: null,

    init: function( x, y, settings ) {
        ig.input.bind( ig.KEY.SPACE, 'start');
        this.durationTimer = new ig.Timer();
        this.displayTime = 2;

        ig.music.add( 'media/sounds/Funny_sunny_Island.*', "Intro" );
        ig.music.loop = true;
        ig.music.volume = .5;
        ig.music.play("Intro"); 
    },
        
    update: function() {
        this.parent();
        if(ig.input.pressed('start')){
            console.log('leaving Intro - music should stop');
            ig.music.stop("Intro");
            ig.system.setGame(StartScreen)  //<--???
        }
    },
		
    draw: function() { ........... and so on ...

Can someone help me to understand please?

1 decade ago by dominic

The .stop() method doesn't take any parameters. It always stops the currently playing track. That said, the extra parameter shouldn't cause any problems.

I see no reason why the track shouldn't stop when you switch game classes. Are you maybe calling ig.music.play() anywhere in the StartScreen?

1 decade ago by nightbyter

Thank you for the fast reply dominic,
yes indeed, i do call .play() in StartScreen.

So my Intro music just start playing again, i asume. So i need to "free" this sound fromthe list to avoid this?
But how?

nightbyter
Page 1 of 1
« first « previous next › last »