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();
这段代码在模拟器中能展示阴影效果,在真机中展示不出来