[LayaAirIDE 2.0]一个关于getPixels的问题
空工程中代码如下:
Main.js:
const Sprite = Laya.Sprite;
const Text = Laya.Text;
const Texture = Laya.Texture;
Laya.init(800, 600);
var txt = new Text();
txt.pos(200, 200);
txt.color = "#FFFFFF";
txt.text = "000000";
Laya.stage.addChild(txt);
var spr = new Sprite();
spr.size(50, 50);
Laya.stage.addChild(spr);
spr.texture = "images/circle.png";
txt.text = spr.texture.getPixels(25,25,1,1);希望通过使用getPixels方法使txt的文本内容变成spr.texture的(25,25)处的那一像素。
结果是:spr正常显示,但txt的内容显示为"null"。
推测是getPixels方法的实现或我的用法有问题,求修复或指正。
附上附件。
Main.js:
const Sprite = Laya.Sprite;
const Text = Laya.Text;
const Texture = Laya.Texture;
Laya.init(800, 600);
var txt = new Text();
txt.pos(200, 200);
txt.color = "#FFFFFF";
txt.text = "000000";
Laya.stage.addChild(txt);
var spr = new Sprite();
spr.size(50, 50);
Laya.stage.addChild(spr);
spr.texture = "images/circle.png";
txt.text = spr.texture.getPixels(25,25,1,1);希望通过使用getPixels方法使txt的文本内容变成spr.texture的(25,25)处的那一像素。
结果是:spr正常显示,但txt的内容显示为"null"。
推测是getPixels方法的实现或我的用法有问题,求修复或指正。
附上附件。
没有找到相关结果
已邀请:
要回复问题请先登录
2 个回复
Aar0n
赞同来自:
mcube_12139
赞同来自: