In my game I present the deck to the player so they can choose a card
I use the following method to add the deck to the stock:
It is called from the onEnterStage at the correct state
The issue is the first time this happens, the cards are displayed vertically like so
Before:

for both players, after refreshing the browser while the game is in the cutCard state the cards are displayed horizontally with the correct overlap
After:

From what I can tell the generated Css looks the same before and after the refresh except for the height of the parent div, which leads me to believe it is being calculated by either setOverlap or addToStockWithId
Parent Div:
Before:

After:

StockItem:
Before:

After:
I use the following method to add the deck to the stock:
Code: Select all
spreadDeck: function(cards, parent) {
var stock = new ebg.stock();
stock.create(this, $(parent), this.cardWidth, this.cardHeight);
dojo.connect(stock, 'onChangeSelection', this, 'onDeckSelect');
stock.image_items_per_row = 14;
stock.setOverlap(20, 0);
var counter = 0;
for(let i in cards) {
stock.addItemType(cards[i].id, counter++, g_gamethemeurl + 'img/cards.png', 13);
stock.addToStockWithId(cards[i].id, cards[i].id);
}
},
Code: Select all
onEnteringState: function (stateName, args) {
console.log('Entering state: ' + stateName);
switch (stateName) {
case 'cutCard':
dojo.style('cutCard', 'display', 'none');
this.spreadDeck(args.args.deck, 'fullDeck');
dojo.style('fullDeck', 'display', 'inline-block');
case 'dummmy':
break;
}
},
Before:
for both players, after refreshing the browser while the game is in the cutCard state the cards are displayed horizontally with the correct overlap
After:
From what I can tell the generated Css looks the same before and after the refresh except for the height of the parent div, which leads me to believe it is being calculated by either setOverlap or addToStockWithId
Parent Div:
Before:
After:
StockItem:
Before:
After: