Update player color in panels

Game development with Board Game Arena Studio
Post Reply
User avatar
shadowphiar
Posts: 124
Joined: 01 January 2017, 16:07

Update player color in panels

Post 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,
User avatar
Victoria_La
Posts: 665
Joined: 28 December 2015, 20:55

Re: Update player color in panels

Post 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)
       }
User avatar
shadowphiar
Posts: 124
Joined: 01 January 2017, 16:07

Re: Update player color in panels

Post by shadowphiar »

Thanks!
Post Reply

Return to “Developers”