[LayaAir 2.0]sprite.loadImage加载图片怎么设置要显示的x,y坐标和宽高?

代码:
import TiledMap = Laya.TiledMap;
class GameMain{
private tMap:TiledMap;

constructor()
{
Laya.init(935, 224, Laya.WebGL);

this.tMap = new TiledMap();

var viewRect: Laya.Rectangle = new Laya.Rectangle(0, 0, Laya.stage.width, Laya.stage.height);

this.tMap.createMap("res/mario_map/new_map2.json", viewRect, Laya.Handler.create(this,this.initMap));

}

private initMap(): void {

var layer = this.tMap.getLayerByIndex(9);
var gs = layer.getObjectByName('others1');

var sp: Laya.Sprite = new Laya.Sprite();
sp.loadImage("res/smallWalkRight.png");

sp.pos(gs.x, gs.y);
layer.addChild(sp);
}
}

new GameMain();
sprite显示出了整张图片:

menu.saveimg_.savepath20190214100053_.jpg

 
已邀请:

Aar0n

赞同来自:

用 graphic.drawTexture

要回复问题请先

商务合作
商务合作