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

5 years ago by FlameFrenzy

I'm making a platformer that has multiple "rooms" (loaded as new levels) per actual Level. There are doors between these rooms in case the player missed something that is needed to complete the current level.

I also have entities like a 1-up and HP Restore lying around. If you go through a door and come back, these show back up again. I don't want this to happen until the page is refreshed.

I want to preferably call something from the entities .check function. I attempted to get a bit hacky and figure out how to remove it from the level's data but I failed.

What would be a way to accomplish this?


5 years ago by alexandre

The local storage browser standard is your friend in cases like this. A very useful impact plugin -- I've used it in a project of mine for the same reasons that you mention -- for this is also available. This lets you maintain state across level visits, nicely keeping it in one place accessible game-wide.

5 years ago by FlameFrenzy

I may just not be reading it right or something, but how would I make this keep up with entities that I place in my levels on weltmeister? I already have a way of keeping up with HP, Lives and such between levels, but I want the items that increase these values to be a 1 time deal.

5 years ago by alexandre

I had the same goal of keeping track of what unclaimed items and unsprung traps remained in a room when I returned to it. So I did this:

1. I name all entities I want to track

2. When a level is loaded, I look for its key (named after the level) in my local storage:
- If its key is not found, I create a new object in said storage, and populate it with the names of the items to track, setting values to true for present/unsprung/etc.
- If its key is found, I remove those entities and pre-spring those traps whose values are set to false. Something like this:
var traps ="EntityTrap");
_.each(traps, function(t){ ![levelName].get( && t.spring(); });

var items ="EntityItem");
_.each(items, function(it){ ![levelName].get( && it.kill(); });

3. As the level is played and items picked up, traps sprung, etc., I update the storage object, setting to false those items that were picked up, the traps that were sprung, etc.

5 years ago by drhayes

The ready method on Entity is a great place for this kind of check, too. That way each Entity "knows" it's a one-time use or not and can check for itself.

You could probably figure out a way to get it to set its name to some random string when you place it in Weltmeister too... maybe modify WM to look for a property on the entity when you place it or something? It's kind of a pain to do unique names but maybe not so bad if there aren't too many of these things across the level.
Page 1 of 1
« first « previous next › last »