Stock automatic overlap

Game development with Board Game Arena Studio
Post Reply
User avatar
Alex_erson
Posts: 9
Joined: 22 October 2015, 20:37

Stock automatic overlap

Post by Alex_erson »

Hello,

I noticed that for Alhambra, the stock overlap is dynamic (meaning it changes depending on the width of the page).
I did some research in the documentation and the forum but couldn't find how this is done.

Is there a simply parameter to change to be able to use that or do I need to do it myself?

Alhambra being a BGA-developed game, I think the sources are not available so I couldn't find the answer.
Or if you have another game in mind that allows this, I can dig into the code myself.

Thanks !
User avatar
Benoit314
Posts: 82
Joined: 02 April 2020, 22:12

Re: Stock automatic overlap

Post by Benoit314 »

You can have a look since stock is a JavaScript component.
I suppose the game changes the overlap to fit the width of the page.
User avatar
RicardoRix
Posts: 2541
Joined: 29 April 2012, 23:43

Re: Stock automatic overlap

Post by RicardoRix »

you can override a JS function:

onScreenWidthChange: function()

Probably best to look at the project, I don't know if this was the way it's done.
User avatar
Alex_erson
Posts: 9
Joined: 22 October 2015, 20:37

Re: Stock automatic overlap

Post by Alex_erson »

Ok, that's kind of what I expected: there is nothing out-of-the-box.

7 wonders is doing so as well but is closed source also. I'll keep looking. Maybe I'll find a game with accessible sources so I can save some time 😊.

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

Re: Stock automatic overlap

Post by RicardoRix »

does something like this work?
onScreenWidthChange: function()
{
console.log('onScreenWidthChange');
var width = $('stock_container').offsetWidth;

// change stock items overlap here with stock.setOverlap( horizontal_percent, vertical_percent )

},

or I've just noticed this, which I think is new:
autowidth

Stock does not play well if you attempt to inline-block it with other blocks, to fix that you have to set this flag which will calculate width properly

mystock.autowidth = true;
Post Reply

Return to “Developers”