I’m using the tilesheet api to draw my sprites, i now added a click event to the sprite and noticed that the sprites width/height is set to the windows dimensions rather than the width of the image. Why is that?
Sprite class:
private var tilesheet:Tilesheet;
private var bitmapData:BitmapData;
private var sprite:Sprite;
public function new()
{
super();
bitmapData = Assets.getBitmapData('img/tree_static.png');
tilesheet = new Tilesheet(bitmapData);
sprite = new Sprite();
tilesheet.addTileRect(new Rectangle(0, 0, 121, 149));
tilesheet.drawTiles(sprite.graphics, [0, 0, 0], true);
addChild(sprite);
this.addEventListener(MouseEvent.CLICK, click);
}
Dunno if relevant but here’s the code for resizing
(Which isn’t 100% working i might add)
function resize(e)
{
if (!inited) init();
var stageScaleX:Float = stage.stageWidth / Settings.NOMINAL_WIDTH;
var stageScaleY:Float = stage.stageHeight / Settings.NOMINAL_HEIGHT;
var stageScale:Float = Math.min(stageScaleX, stageScaleY);
Lib.current.x = 0;
Lib.current.y = 0;
Lib.current.scaleX = stageScale;
Lib.current.scaleY = stageScale;
if(stageScaleX > stageScaleY) {
Lib.current.x = (stage.stageWidth - Settings.NOMINAL_WIDTH * stageScale) / 2;
} else {
Lib.current.y = (stage.stageHeight - Settings.NOMINAL_HEIGHT * stageScale) / 2;
}
}