Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript"';x';是未定义的“;当定义前几行时_Javascript_Html_Phaser Framework - Fatal编程技术网

Javascript"';x';是未定义的“;当定义前几行时

Javascript"';x';是未定义的“;当定义前几行时,javascript,html,phaser-framework,Javascript,Html,Phaser Framework,变量layer在对象前几行定义,并在该对象中更改,但不允许我给它一个值,如下所示: //using the phaser game engine var layer; var map; Game.prototype = { create: function() { map = game.add.tilemap('testlevel'); map.addTilesetImage('grassland'); map.setCollisionByExclusion([1]); lay

变量
layer
在对象前几行定义,并在该对象中更改,但不允许我给它一个值,如下所示:

//using the phaser game engine
var layer;
var map;
Game.prototype = {
 create: function() {
  map = game.add.tilemap('testlevel');
  map.addTilesetImage('grassland');
  map.setCollisionByExclusion([1]);
  layer = map.createLayer('layer1');
  layer.resizeWorld(); //here is where the error occurs
 };
};

如果看不到更多的代码,很难准确地知道,但这看起来像map.createLayer('layer1');正在返回undefined,因此您正在对未定义的对象调用方法(resizeWorld)


我会检查createLayer的返回值。

你能把错误的文本发布到这里吗?声明的和定义的<代码>之间有差异。您已经完成了前者,但很可能是
map.createLayer()
失败并返回未定义的值。是否是
map.createLayer(…)
返回null或未定义的值?