[LayaAir 2.0]sprite.loadImage加载图片怎么设置要显示的x,y坐标和宽高?
代码:
import TiledMap = Laya.TiledMap;sprite显示出了整张图片:
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();
要回复问题请先登录
1 个回复
Aar0n
赞同来自: