Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.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 使用光标在tilemap中多选分幅_Javascript_Arrays_Phaser Framework_Jstilemap - Fatal编程技术网

Javascript 使用光标在tilemap中多选分幅

Javascript 使用光标在tilemap中多选分幅,javascript,arrays,phaser-framework,jstilemap,Javascript,Arrays,Phaser Framework,Jstilemap,我正在使用tilemap和phaser框架开发一个游戏。我想使用phaser(光标)选择tilemap上的多个坐标,然后可以存储到数组中。使用移相器是否可行?为我提供一些解决方案。您可以直接在游戏中工作,并获得场景的每个位置。 您可以尝试以下方法: var positions = [], text; function create() { text = game.add.text(game.world.centerX / 2, game.world.centerY / 2, '

我正在使用tilemap和phaser框架开发一个游戏。我想使用phaser(光标)选择tilemap上的多个坐标,然后可以存储到数组中。使用移相器是否可行?为我提供一些解决方案。

您可以直接在游戏中工作,并获得场景的每个位置。 您可以尝试以下方法:

var positions = [],
    text;

function create() {
    text = game.add.text(game.world.centerX / 2, game.world.centerY / 2, '', { fill: '#ffffff' });

    game.input.onDown.add(function(pointer, event) { 
        listener();
    }, this);

}

function update() {

}

function listener() {
    var p = [game.input.mousePointer.x, game.input.mousePointer.y];
    positions.push(p);

    text.text = "You clicked in position: " + p;

    console.log(positions);
}

你能说得更具体些吗?选择多个坐标时,您是指在tilemap中创建的对象吗?或者您只是想将位置(x,y)存储在您单击的位置?很抱歉延迟回复。实际上,每当我点击tilemap时,我都想存储所选的坐标(x,y位置)。