From 892b24f0ca2913913e06437e6818f31453ae2e51 Mon Sep 17 00:00:00 2001 From: Ansis Brammanis Date: Wed, 6 Jan 2016 12:14:56 -0800 Subject: [PATCH] fail and warn when spriteatlas is full ref #1633 --- js/symbol/sprite_atlas.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/js/symbol/sprite_atlas.js b/js/symbol/sprite_atlas.js index 41004b58e5c..d25b3efa573 100644 --- a/js/symbol/sprite_atlas.js +++ b/js/symbol/sprite_atlas.js @@ -118,7 +118,8 @@ SpriteAtlas.prototype.allocateImage = function(pixelWidth, pixelHeight) { // We have to allocate a new area in the bin, and store an empty image in it. // Add a 1px border around every image. var rect = this.bin.allocate(packWidth, packHeight); - if (rect.w === 0) { + if (rect.x < 0) { + console.warn('SpriteAtlas out of space.'); return rect; } @@ -145,7 +146,7 @@ SpriteAtlas.prototype.getImage = function(name, wrap) { var width = pos.width / pos.pixelRatio; var height = pos.height / pos.pixelRatio; var rect = this.allocateImage(width, height); - if (rect.w === 0) { + if (rect.x < 0) { return rect; }