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 aclelland

Hi,

I'm trying to add a level name to my level files so that I can display a sort of "The Haunted House Complete!" message at the end of each level.

Initially I thought of just adding it into the JSON for each level in the .js file that the level editor creates. This works fine as long as I don't save the map since the editor removes my custom JSON data :(

My other solution is to add an extra parameter to the game.loadLevel method which takes a level name but this doesn't seem very neat since the name of Level 2 needs to be stored in the Level 1 map file.

Any other suggestions or am I missing something in weltmeister to do what I want :)

Thanks,
Alan

1 decade ago by dominic

Get the void entity from the Biolab Disaster Entity Pack, put one in your level and give it those keys/values in Weltmeister:

name:levelInfo
title:The Haunted House

Then, in your loadLevel() method you can do something like this:

loadLevel: function( data ) {
	this.parent( data );
	
	var info = this.getEntityByName( 'levelInfo' );
	if( info && info.title ) {
		this.currentLevelTitle = info.title;
	}
	else {
		this.currentLevelTitle = "Untitled";
	}
}

1 decade ago by stahlmanDesign

I hadn't thought about that. Using the void entity is a very cool way to assign data about an individual level. I suppose you could also assign other things the same way, such as time required to finish level, or levelDifficulty etc.

1 decade ago by aclelland

Sounds like a good idea, I was thinking of using the Player object to do that but I'm created a specific levelinfo entity for that sort of information (which is just an edited void.js)
Page 1 of 1
« first « previous next › last »