I'm using a Stock component to hold two gold cubes in the play area. When a player claims gold, the cubes slide from the play area to the player panel, then disappear. I didn't write any animation code, I'm just using the built-in stock.removeFromStock() like so:
If the player only claims one gold cube, it slides to the player panel and the remaining gold cube centers itself in the zone. However, if the player claims both of the gold cubes in the zone, they both animate as expected to the player panel, but then an animation plays in the zone of a ghost cube sliding to the center, even though there are no cubes left there.
Here's a gif of the glitch:
https://imgur.com/a/iWGBuGp
Is it a bug or am I mis-using the Stock component?
Code: Select all
awardGoldToPlayer: function(player_id, gold, from_stock_index)
{
let gold_element = $("gold_" + player_id);
if (from_stock_index != null)
for (let i = 0; i < gold; i++)
this.goldZones[from_stock_index].removeFromStock(0, gold_element);
gold_element.innerHTML = toint(gold_element.innerHTML) + gold;
},
Here's a gif of the glitch:
https://imgur.com/a/iWGBuGp
Is it a bug or am I mis-using the Stock component?