你的问题有两个方法可以解决,第一个方法如下:
var w:int = 110;
var h:int = 40;
var btn:Sprite = new Sprite();
btn.size(w, h);
btn.graphics.drawRect((stageWd - w) * 0.5, (stageHt - h) * 0.5-50, w, h, "#FF7F50");
btn.graphics.fillText("确 定", (stageWd) * 0.5 , (stageHt - h) * 0.5-43, "25px SimHei", "#FFFFFF", "center");
Laya.stage.addChild(btn);
var hitArea:HitArea = new HitArea();
var graphics:Graphics = new Graphics();
graphics.drawRect((stageWd - w) * 0.5, (stageHt - h) * 0.5-50, w, h, "#FF7F50");
hitArea.hit = graphics;
btn.hitArea = hitArea;[/code][code]第二种方法:
[code]var w:int = 110;
var h:int = 40;
var btn:Sprite = new Sprite();
btn.size(w, h);
btn.graphics.drawRect(0,0, w, h, "#FF7F50");
btn.graphics.fillText("确 定", (stageWd) * 0.5 , (stageHt - h) * 0.5-43, "25px SimHei", "#FFFFFF", "center");
Laya.stage.addChild(btn);
btn.pos((stageWd - w) * 0.5, (stageHt - h) * 0.5-50);[/code]