微信小游戏阴影无效
发布于 5 年前 作者 chaoluo 18049 次浏览 来自 问答

function init() 

{

var canvas = wx.createCanvas();

Laya.init(400, 400, canvas);

 

wx.setPreferredFramesPerSecond(1);

requestAnimationFrame(draw);

}

function draw() 

{

Laya.stage.draw();

requestAnimationFrame(draw);

}

var Laya =

{

init: function (width, height, canvas) {

var context = canvas.getContext(‘2d’);

canvas.width = width;

canvas.height = height;

this.stage = new Stage();

this.stage.init(width, height, context);

}

}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function Stage() 

{

 

this.width = 0;

this.height = 0;

this.context = null;

this.init = function (width, height, context) { this.width = width; this.height = height; this.context = context; };

  

this.draw = function () { 

console.log(“123”)

this.context.clearRect(0, 0, this.width, this.height);

this.context.fillStyle = “#fff”;

this.context.fillRect(0, 0, this.width, this.height);

 

this.context.font = “20px Times New Roman”;

this.context.fillStyle = “blue”;

this.context.fillText(“Sample String”, 5, 30);

this.context.shadowOffsetX = 2;

this.context.shadowOffsetY = 2;

this.context.shadowBlur = 20;

this.context.shadowColor = “#555”;

 

}

 

}

init();

这段代码在模拟器中能展示阴影效果,在真机中展示不出来

5 回复

阴影是 Laya 引擎提供的接口,建议到 Laya 引擎论坛提问。

另外我提供的代码,复制下就可以运行,再次说明我的代码和Laya引擎没有关系

不好意思,之前没看清楚。目前小游戏的 Canvas2DContext 确实不支持以下属性:

  • shadowOffsetX

  • shadowOffsetY

  • shadowBlur

  • shadowColor


请静待后续完善。

还有个问题,Canvas2DContext如何消除锯齿?

还有canvas3d为什么消除锯齿不起作用?

Laya 是我自己的起的名字,和Laya引擎没有关系

回到顶部