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 TigerJ

this may be a false assumption, but I have noticed when I specify a track by name with
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);

1 decade ago by TigerJ

Well I decided to set the property during my level loading switch and my logic in the update portion of my main.js is working perfect now. I still think that the currentIndex should update when .play('name') is called though.

:)

switch(this.currentLevel)
{
     case 0:
          ig.music.currentIndex=0;
          ig.music.stop();
          ig.music.play('CloudyWithAChanceOfDevastationIntroChunk');
          ig.music.loop=false;
          ig.game.letsStartLooping=false;
          ig.game.levelToLoad=LevelTitlescreen;
          ig.game.score=0;
          break;

Here is a baked version with the "conditional" looping in place
http://devbriggs.com/cloudy/
There is a slight gap when the tracks change. I do not know how to eliminate it.
Page 1 of 1
« first « previous next › last »