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 bram

Hello ImpactJS,

I'm trying to figure out how to get different music on each level. Thus far I have failed :(. I really hope someone knows how to do this and can help me with this.

Bram

1 decade ago by stillen

How are you loading each level? Are you using one of the director/level loading plugins? Depending on what you are using, there are different hooks to use. With some more detail, we can get you a working answer.

1 decade ago by Joncom

Yeah, showing us how you're changing levels would be a good start.

1 decade ago by bram

I use the levelchange code form jump n run

ig.module(
	'game.entities.levelchange'
)
.requires(
	'impact.entity'
)
.defines(function(){
	
EntityLevelchange = ig.Entity.extend({
	_wmDrawBox: true,
	_wmBoxColor: 'rgba(0, 0, 255, 0.7)',
	
	size: {x: 8, y: 25},
	level: null,
	
	triggeredBy: function( entity, trigger ) {
		if( this.level ) {
			var levelName = this.level.replace(/^(Level)?(\w)(\w*)/, function( m, l, a, b ) {
				return a.toUpperCase() + b;
			});
			
			ig.game.loadLevelDeferred( ig.global['Level'+levelName] );
		}
	},
	
	update: function(){}
});
});

And in main.js I use this.loadLevel ( levelname );

1 decade ago by Joncom

After this.loadLevel in main.js, and after ig.game.loadLevelDeferred in levelchange.js, add a line that sets what song is playing.

1 decade ago by bram

Quote from Joncom
After this.loadLevel in main.js, and after ig.game.loadLevelDeferred in levelchange.js, add a line that sets what song is playing.


I'm still very new to this so what do I write behind these lines:

this.loadLevel( LevelDorm1 );

and

ig.game.loadLevelDeferred( ig.global['Level'+levelName] );
Page 1 of 1
« first « previous next › last »