Page 1 of 1

CardStock items disappear (seems mostly iphone related)

Posted: 03 January 2021, 02:29
by MikeIsHere
For my game cribbage I create the cardstock following the hearts tutorial
and I have a function for dealing the hand

Code: Select all

dealHand: function (cards) {	   
	for (var i in cards) {                    
		this.playerHand.addToStockWithId(this.getCardTypeId(cards[i]), cards[i].id);
	}

	this.playerHand.changeItemsWeight(this.orderByRank(this.playerHand.item_type));
},

orderByRank: function(cards) {
	var weight = {};
	for (var i in cards) {
		//deconstruct i as type and suit
		var color = ~~(i/14);
		var rank = (i%14);
		
		weight[i] = rank * 4 + color;
	}
	return weight;
},
There have been reports that not all 6 cards show up for display. I never encountered this on PC/Pixel, but have seen it on my wife's iPhone

Which is pretty standard, what is not standard is I change the weight of the cards based on Rank not on Suit. An early version of this game had a toggle button that would allow you to sort by either, it was removed because sort by suit was never helpful, so that is why orderByRank is a function.

Does anyone know if changing weight could cause cards to not display. Note a refresh of the screen fixes the issue. The issue is rare but enough have mentioned it so it should be looked into. Has anyone run into this before?

Other than that I can't think of what would be the offending code.

Thank you
Mike

Re: CardStock items disappear (seems mostly iphone related)

Posted: 03 January 2021, 16:58
by Victoria_La
After changing on weight you also need to force stock to relayout, I think its something like stock.resetItemsPosition();
Also make sure all weights are diffrent.

Re: CardStock items disappear (seems mostly iphone related)

Posted: 03 January 2021, 18:07
by MikeIsHere
Thank you for the suggestion, I can try it

but the documentation says
resetItemsPosition()

If you moved an item from the stock control manually (ex: after a drag'n'drop) and want to reset their positions to their original ones, you can call this method.
So it is not a manual move

Also my wife experience a card disappearing in Tock. I tried to look through their bugs but most of them are in French.