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 saloon12yrd

Hi all,

I've run into a strange issue that I can't explain.

My index.html has the usual #canvas element for the game and below that another div (#controls) which contains elements such as the health display etc.
The index.html includes an additional hud.js which does little less than binding all the GUI elements to a JS object:

$(document).ready(function() {
    [...]
    Hud = {
        health: $('#healthGui'),
        currentWeapon: $('#currentWeaponGui'),
        ammo: {
            rocket: $('#ammoRocketsGui'),
            plasma: $('#ammoPlasmaGui'),
            crypto: $('#ammoCryptoGui'),
            ionizer: $('#ammoIonGui')
        }
    };
    [...]
});

I refer to that Hud object in my game entities whenever they need updating. This works flawlessly in the game itself but Weltmeister refuses to load the levels and 'hangs'.

I assumed this is because the Hud object is not present (since it is created in a js file Weltmeister doesn't include) but sometimes accessed in the entities' init() method but even if I do

        init: function(x, y, settings) {
            [...]            

            // update the HUD
            if (Hud != null) {
                Hud.health.text(this.health);
            [...]            
        },

Weltmeister won't load the levels.

Any hints how to solve this?

Thanks

1 decade ago by dominic

You can check if you're running inside Weltmeister and skip your hud initialization then:

if( !ig.global.wm ) { // not in wm?
    // init hud!
}

1 decade ago by saloon12yrd

Thx for that Dominic,

naturally it works but I see no reason why a check against null shouldn't do the same? Anyways it works with the check against ig.global.wm.

Thanks
Page 1 of 1
« first « previous next › last »