From 0be26c32c4ef573298fe90a8670da7ba9ad9ffa8 Mon Sep 17 00:00:00 2001 From: Erico Vieira Porto Date: Sat, 3 Dec 2016 21:15:43 -0200 Subject: [PATCH] allow different boxsizes --- src/animap.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/animap.js b/src/animap.js index a49ebc3..b43c5e9 100644 --- a/src/animap.js +++ b/src/animap.js @@ -32,14 +32,23 @@ animap.removeById = function(id){ } function mapAnimationSprite(animationImgName, animationLine, x, y) { + //check if different box + //if animationImgName ends with _number like _32 , _72, + //use this number as boxsize instead of 64 + this['box'] = 64; + var tmp = animationImgName.split('_'); + tmp = parseInt(tmp[tmp.length-1]); + if(tmp>1){ + this['box'] = tmp; + } + this['draw'] = function(){ animap.drawMapAnimation(this) }; this['mapx'] = x * 32; this['mapy'] = (y - 1) * 32; - this['box'] = 64; this['img'] = resources.animations[animationImgName]; this['animationLine'] = animationLine; this['frame'] = 0; - this['maxframe'] = Math.floor(resources.animations[animationImgName].width/64); + this['maxframe'] = Math.floor(resources.animations[animationImgName].width/this['box']); this['id'] = Math.floor(Math.random()*100000); }