Page 1 of 1

Stock automatic overlap

Posted: 29 January 2021, 00:03
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 !

Re: Stock automatic overlap

Posted: 29 January 2021, 00:34
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.

Re: Stock automatic overlap

Posted: 29 January 2021, 00:52
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.

Re: Stock automatic overlap

Posted: 05 February 2021, 16:09
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

Re: Stock automatic overlap

Posted: 05 February 2021, 16:57
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;