1 decade ago by TigerJ
this may be a false assumption, but I have noticed when I specify a track by name with
ig.music.currentIndex remains the same as it was even though the track has changed.
My intention was to preload several tracks and add a boolean value like:
And then add them later in the init() of my main.js
And finally test the boolean and track index to determine if it was appropriate to begin looping post introduction segment during my update. like so:
the boolean prevents this from being processed twice unless the level changes, as seen below and this is where I have noticed ig.music.currentIndex does not change as the track changes using .play([name])
ig.music.play('mynamehere');
ig.music.currentIndex remains the same as it was even though the track has changed.
My intention was to preload several tracks and add a boolean value like:
musicTitleIntro: new ig.Sound( 'media/sound/musics/CloudyWithAChanceOfDevastationIntroChunk.*', false), musicTitleLoop: new ig.Sound( 'media/sound/musics/CloudyWithAChanceOfDevastationLoopChunk.*', false ), BlackSkyBlackHeartIntro_2: new ig.Sound( 'media/sound/musics/BlackSkyBlackHeartIntro_2.*', false), BlackSkyBlackHeartLoop_2: new ig.Sound( 'media/sound/musics/BlackSkyBlackHeartLoop_2.*', false ), letsStartLooping:false,
And then add them later in the init() of my main.js
ig.music.add( this.musicTitleIntro,'CloudyWithAChanceOfDevastationIntroChunk' ); ig.music.add( this.musicTitleLoop,'CloudyWithAChanceOfDevastationLoopChunk' ); ig.music.add( this.BlackSkyBlackHeartIntro_2,'BlackSkyBlackHeartIntro_2' ); ig.music.add( this.BlackSkyBlackHeartLoop_2,'BlackSkyBlackHeartLoop_2' );
And finally test the boolean and track index to determine if it was appropriate to begin looping post introduction segment during my update. like so:
if(!this.letsStartLooping && ig.music.currentTrack==ig.music.tracks[1]) { ig.music.loop=true; this.letsStartLooping=true; }
the boolean prevents this from being processed twice unless the level changes, as seen below and this is where I have noticed ig.music.currentIndex does not change as the track changes using .play([name])
ig.game.letsStartLooping=false; ig.music.loop=false; ig.game.isPlayingMusic=true; ig.game.loadLevelDeferred(LevelBlahBlahBlah);