尝试制作随机纹理,我有以下代码:
//doesn't work
var selections = [".","1","2","3","4","5","6","7","8","A","B","D","E","F"]
var d = [];
for (var i = 0; i < 15; i++){
var inner = [];
for (var j = 0; j < 15; j++){
var idx = Math.floor(Math.random() * selections.length);
var item = selections[idx];
inner.push(item);
}
d.push(inner.join(''));
}
//console.log(burd, data)
console.log(d);
game.create.texture('rand',d, pixelWidth, pixelHeight);
由于某种原因它没有加载(或仅显示为背景) 我尝试过只使用硬编码值并且工作正常。
//works
var burd = [
"A682EA1D51D8D46",
"5.1628F1.F81757",
"1A6F2672B234AE1",
"B.8BB42746AFA22",
"E4.113385.D1.D.",
"6EF22BA.66181D3",
"7E18A7DD6F8F3D2",
".D47D225761427D",
"B4BDA5DE..778E7",
"1B46.BEF48321D8",
"FF6.7.347746D2.",
"A2AF57B4B4F4.DD",
"EAD335264158B14",
"A133FB31E4.E728",
"FAF52EBF7.3E81D"];
game.create.texture('burd', burd, pixelWidth, pixelHeight);
game.add.sprite(300, 300, 'burd');
我的代码中有错误吗?移相器的问题? (使用2.6.2), 完整代码:https://gist.github.com/blakedallen/f771d8e0615ff8d35f0630db6a10bd6d