When it is the first time I open the game and play everything is fine
after a couple of moves, players get new turns, some cards fly around(players get resources, trade etc) and then when I hit page refresh to start a new game some of the cards are smaller:
Note that this happens to only to cards. The thing that is common with all cards is that they animate. The cards animate when player receives a new resource. So maybe I thought some old code was continuing to run on the background even when the player refreshed the page, so I made sure all the old animations stopped when the player hit refresh. This didn't solve the problem.
Another thing that was interesting was, the cards on the left bottom and the cards in the bank are totally different sprites. They have nothing in common except for their texture (bank cards don't even animate). So I'm guessing the texture pack didn't load right specifically for the 2 types of cards shown in this image. Note that each game different cards are smaller, but once a certain texture is smaller 'ALL' of the sprites that use that texture becomes smaller.
How can I fix this?
My loading function is as below
export function loadImages() {
PIXI.loader
.add("tile_lumber", "../images/tile_lumber.svg")
.add("tile_brick", "../images/tile_brick.svg")
.add("tile_wool", "../images/tile_wool.svg")
.add("tile_grain", "../images/tile_grain.svg")
.add("tile_ore", "../images/tile_ore.svg")
.add("tile_desert", "../images/tile_desert.svg")
.
.
.
.on("progress", loadProgressHandler)
.load(GameUICore.setup);
}
export function setup() {
assetsLoaded = true
createContainers()
GameUICards.setCardProps() //The cards on left bottom created here
GameUIActions.createActions()
GameUIPlayers.createPlayers() //The cards in bank created here
createTimer()
createKeyboardActions()
app.ticker.add(function (delta) {
animateObjects()
});
}
function animateObjects() {
for (let view of animatingViews) {
view.animate()
}
for (let line of animatingLines) {
line.animate()
}
for (let text of animatingTexts) {
text.animate()
}
removeObjectsWhoseAnimationFinished()
}
You can try to reproduce the problem: http://katan.io/