html52.com
我爱小程序-开发者交流社区

微信小游戏阴影无效

问题模块 框架类型 API/组件名称 终端类型 操作系统 微信版本 基础库版本
API和组件 小游戏 game iOS 6.6.3 game

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();


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


网友回复

焦zl:

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

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

Link:

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

  • shadowOffsetX

  • shadowOffsetY

  • shadowBlur

  • shadowColor


请静待后续完善。

逐风:

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

逐风:

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

Link:

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

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

真正的个人免签约支付接口

云免签H5支付