Player-count CSS mods?

Game development with Board Game Arena Studio
Post Reply
User avatar
cmgames
Posts: 16
Joined: 05 October 2016, 22:14

Player-count CSS mods?

Post by cmgames »

Any way to modify css styles based on number of players?

I need to use a different background image (or, technically, the background position of a sprite image) depending on the number of players.

~Chris
User avatar
RicardoRix
Posts: 2541
Joined: 29 April 2012, 23:43

Re: Player-count CSS mods?

Post by RicardoRix »

sure, use dojo:
dojo.addClass / dojo.removeClass or dojo.toggleClass

You should be able to get the number of players from somewhere like gamedatas.players or gamedatas.playersorder.length
User avatar
Tisaac
Posts: 2736
Joined: 26 August 2014, 21:28

Re: Player-count CSS mods?

Post by Tisaac »

Use a custom attribute on your main container and then.css rule with attribute.selector
User avatar
BaronFraser
Posts: 39
Joined: 10 June 2020, 10:27

Re: Player-count CSS mods?

Post by BaronFraser »

GAME.css

.object-1-player
{
/* styles */
}

.object-2-player
{
/* styles */
}

.object-3-player
{
/* styles */
}

.object-4-player
{
/* styles */
}

.object-5-player
{
/* styles */
}


GAME.game.php

protected function getAllDatas()
{
return array(
'num_players' -> $this->getPlayersNumber()
);
}



GAME.js

setup: function( gamedatas )
{
var num_players = gamedatas.num_players;

var class = "object-" + num_players + "-player";

dojo.addClass("mydiv", "object-x-player");
}
Post Reply

Return to “Developers”