[]DrawPie例子中无法显示遮罩区域
重现步骤,打开http://layaair.ldc.layabox.com ... Image
输入已下代码并执行:
(function()
{
var Sprite = Laya.Sprite;
var Stage = Laya.Stage;
var Texture = Laya.Texture;
var Browser = Laya.Browser;
var Handler = Laya.Handler;
var WebGL = Laya.WebGL;
(function()
{
// 不支持WebGL时自动切换至Canvas
Laya.init(Browser.clientWidth, Browser.clientHeight, WebGL);
Laya.stage.alignV = Stage.ALIGN_MIDDLE;
Laya.stage.alignH = Stage.ALIGN_CENTER;
Laya.stage.scaleMode = "showall";
Laya.stage.bgColor = "#232628";
showApe();
})();
function showApe()
{
// 方法1:使用loadImage
var p = Laya.stage.addChild(new Sprite());
var ape = new Sprite();
p.addChild(ape);
ape.loadImage("../../res/apes/monkey3.png");
//创建遮罩对象
this.cMask = new Laya.Sprite();
//画一个圆形的遮罩区域
this.cMask.graphics.drawPie(80,80,50, 0, 360,"#ff0000");
this.cMask.pivot(80,80);
//Laya.stage.addChild(this.cMask);
Laya.stage.on(Laya.Event.MOUSE_MOVE, this, onMouseMove);
ape.mask = this.cMask;
}
function onMouseMove(){
this.cMask.pos(Laya.stage.mouseX, Laya.stage.mouseY);
};
})();
输入已下代码并执行:
(function()
{
var Sprite = Laya.Sprite;
var Stage = Laya.Stage;
var Texture = Laya.Texture;
var Browser = Laya.Browser;
var Handler = Laya.Handler;
var WebGL = Laya.WebGL;
(function()
{
// 不支持WebGL时自动切换至Canvas
Laya.init(Browser.clientWidth, Browser.clientHeight, WebGL);
Laya.stage.alignV = Stage.ALIGN_MIDDLE;
Laya.stage.alignH = Stage.ALIGN_CENTER;
Laya.stage.scaleMode = "showall";
Laya.stage.bgColor = "#232628";
showApe();
})();
function showApe()
{
// 方法1:使用loadImage
var p = Laya.stage.addChild(new Sprite());
var ape = new Sprite();
p.addChild(ape);
ape.loadImage("../../res/apes/monkey3.png");
//创建遮罩对象
this.cMask = new Laya.Sprite();
//画一个圆形的遮罩区域
this.cMask.graphics.drawPie(80,80,50, 0, 360,"#ff0000");
this.cMask.pivot(80,80);
//Laya.stage.addChild(this.cMask);
Laya.stage.on(Laya.Event.MOUSE_MOVE, this, onMouseMove);
ape.mask = this.cMask;
}
function onMouseMove(){
this.cMask.pos(Laya.stage.mouseX, Laya.stage.mouseY);
};
})();
没有找到相关结果
已邀请:
2 个回复
Aar0n
赞同来自: Chenyazhi
Chenyazhi
赞同来自: