Page 1 of 1

Update player color in panels

Posted: 01 March 2017, 16:38
by shadowphiar
In a game I'm working on, the players' colors are not decided until the end of the first turn. At the start of the game I'm setting player_color to a grey, and then writing distinct colors into database and gameinfos.players when they are decided.

This works for subsequent messages. But the player names stay grey on the player panels (unless the game interface is reloaded, in which case they show up correct).

How can I update the color in the player panels dynamically?

Thanks,

Re: Update player color in panels

Posted: 02 March 2017, 02:40
by Victoria_La
This is done by framework on game initialization. Easiest way of doing it when colors are fixed
is to find these element by id and dojo.style
to change the font color

Something along the lines

Code: Select all

      for ( var player_id in gamedatas.players) {
               var player = gamedatas.players[player_id];
               dojo.style('player_name_'+player_id,'color',"#"+player.color)
       }

Re: Update player color in panels

Posted: 07 March 2017, 22:56
by shadowphiar
Thanks!