forked from noxious/client
pointer fix
This commit is contained in:
parent
69db126754
commit
373987afc2
@ -24,15 +24,13 @@ const mapData = new Phaser.Tilemaps.MapData({
|
|||||||
const { width: tileSizeWidth } = mapData;
|
const { width: tileSizeWidth } = mapData;
|
||||||
const { width, height } = scene.cameras.main;
|
const { width, height } = scene.cameras.main;
|
||||||
const map = new Phaser.Tilemaps.Tilemap(scene, mapData);
|
const map = new Phaser.Tilemaps.Tilemap(scene, mapData);
|
||||||
const tileset: Tileset|null = map.addTilesetImage('default', 'tiles');
|
const tileset: (Tileset|null) = map.addTilesetImage('default', 'tiles');
|
||||||
const layer: Layer|null = map.createBlankLayer('layer', tileset);
|
const layer: (Layer|null) = map.createBlankLayer('layer', tileset);
|
||||||
|
|
||||||
scene.cameras.main.scrollX = - map.widthInPixels / 2;
|
scene.cameras.main.scrollX = - map.widthInPixels / 2;
|
||||||
scene.cameras.main.scrollY = - map.heightInPixels / 2;
|
scene.cameras.main.scrollY = - map.heightInPixels / 2;
|
||||||
|
|
||||||
console.log(layer);
|
const tilemapLayer: Ref<(TilemapLayer|undefined)> = refObj();
|
||||||
|
|
||||||
const tilemapLayer: Ref<TilemapLayer|undefined> = refObj();
|
|
||||||
|
|
||||||
const data: any = [
|
const data: any = [
|
||||||
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
|
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
|
||||||
|
@ -34,16 +34,21 @@ const onPointerMove = (e: Phaser.Input.Pointer) => {
|
|||||||
const py = scene.cameras.main.worldView.y + e.y;
|
const py = scene.cameras.main.worldView.y + e.y;
|
||||||
|
|
||||||
pointer_tile.value = getTile(px, py, props.layer);
|
pointer_tile.value = getTile(px, py, props.layer);
|
||||||
waypoint.value.visible = true;
|
if (pointer_tile.value) {
|
||||||
|
waypoint.value.visible = true;
|
||||||
|
|
||||||
if (pointer_tile.value !== undefined) {
|
|
||||||
// Convert tile coordinates to world coordinates
|
// Convert tile coordinates to world coordinates
|
||||||
const worldPoint = props.layer.tileToWorldXY(pointer_tile.value.x, pointer_tile.value.y);
|
const worldPoint = props.layer.tileToWorldXY(pointer_tile.value.x, pointer_tile.value.y);
|
||||||
waypoint.value.x = worldPoint.x;
|
waypoint.value.x = worldPoint.x + 32;
|
||||||
waypoint.value.y = worldPoint.y;
|
waypoint.value.y = worldPoint.y + 32;
|
||||||
|
} else {
|
||||||
|
waypoint.value.visible = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
onPreUpdate(() => {
|
onPreUpdate(() => {
|
||||||
|
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user