4715关注15060浏览
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();
这段代码在模拟器中能展示阴影效果,在小程序真机中展示不出来
-
至过去的我
2044人对此回答表示赞同
我是未来的你,你现在是不是在年找寻小程序答案。你不要感觉诧异,给你来信原因,就是让你不在后悔。今天去学习如何推广小程序,相信......点击查看更多> -
Mika
13人对此回答表示赞同
Laya是我自己的起的名字,和Laya引擎没有关系
展开130回复分享发布于 6年前评论(0)
收起评论
-
AMELIA美少女
13人对此回答表示赞同
另外我提供的代码,复制下就可以运行,再次说明我的代码和Laya引擎没有关系
展开130回复分享发布于 6年前评论(0)
收起评论
-
断桥残雪
7人对此回答表示赞同
阴影是Laya引擎提供的接口,建议到Laya引擎论坛提问。
展开70回复分享发布于 6年前评论(0)
收起评论
-
酥油茶
4人对此回答表示赞同
还有个问题,Canvas2DContext如何消除锯齿?
展开40回复分享发布于 6年前评论(0)
收起评论
-
NONO小诺
1人对此回答表示赞同
不好意思,之前没看清楚。目前小游戏的Canvas2DContext确实不支持以下属性:
展开10回复分享发布于 6年前评论(0)
收起评论