ippa / jaws

Jaws - HTML5 canvas javascript 2D Game Framework
https://jawsjs.ippa.se
GNU Lesser General Public License v3.0
364 stars 75 forks source link

Sprite.setImage doesn't take into account scale_image #73

Closed videlais closed 1 year ago

videlais commented 11 years ago

Currently, when using setImage with a Sprite, it will ignore any previous set scale_x, scale_y, or scale_image properties. I can't decide if this is an issue or not with setImage. However, if it is not, then should setScale be included in Sprite?

sprite = new jaws.Sprite({image: "path/initial image", scale_image: number});

Basically, should it be:

sprite.setImage("path/new image"); //Internal scaling

or:

sprite.setImage("path/new image"); sprite.setScale(number);

or even:

sprite.setImage(jaws.gfx.retroScaleImage("path/new image"), sprite.scale);

ippa commented 11 years ago

Hm, I can see this being slightly confusing. Cause Sprite(scale_image: X) isn't the same as sprite.setScale(x).

scale_image argument to Sprite() prescales the image (with a simple algo resulting in retrostyle hard borders).

setScale(x) sets internal variable scale_x and scale_y which is used at drawtime. So scale_x/scale_y should "survive" a setImage().

prescaling with scale_image-argument is also available in SpriteSheet(), Animation() etc..