Disconnect class ?

Game development with Board Game Arena Studio
User avatar
Coin-coin le Canapin
Posts: 163
Joined: 31 January 2013, 19:00

Re: Disconnect class ?

Post by Coin-coin le Canapin »

I've done this and it seems to work as expected :

Code: Select all

        connectClass: function(className, event, handler)
        {
           var list= dojo.query("."+className);
            this.connections[className] = [];
            for(var i=0;i<list.length;i++) {
                var element = list[i];
                this.connections[className].push({ 
                    className: className, 
                    element: element, 
                    event: event,
                    handle: dojo.connect(element, event, this, handler)
                });
           }           
        }

Code: Select all

        disconnectClass: function(className) {
            if(className in this.connections) {
                for(var i=0;i<this.connections[className].length;i++) {
                    connection = this.connections[className][i];
                    dojo.disconnect(connection.handle);
                }
                delete this.connections[className];
            }
        }
User avatar
pikiou
Posts: 389
Joined: 03 October 2011, 05:36

Re: Disconnect class ?

Post by pikiou »

You're modifying this.connectClass() and this.connections, which are part of the library of BGA.
So better rename them if you want your game to survive future BGA updates which would make use of this.connect, this.disconnect or this.disconnectAll.
User avatar
Coin-coin le Canapin
Posts: 163
Joined: 31 January 2013, 19:00

Re: Disconnect class ?

Post by Coin-coin le Canapin »

Right, I was asking myself the question instead of asking here :D
User avatar
Rudolf
Posts: 566
Joined: 24 December 2011, 23:04

Re: Disconnect class ?

Post by Rudolf »

also better store connection with node? what do you think Pikiou?
Post Reply

Return to “Developers”