mirror of
https://github.com/billsonnn/nitro-react.git
synced 2024-11-23 14:40:50 +01:00
fix click detection
This commit is contained in:
parent
aac2c49469
commit
a33f06ad27
@ -6,7 +6,7 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
height: 300px;
|
height: 300px;
|
||||||
min-height: 300px;
|
min-height: 300px;
|
||||||
overflow-x: scroll;
|
overflow: scroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
.color {
|
.color {
|
||||||
|
@ -127,9 +127,8 @@ export class FloorplanEditor extends PixiApplicationProxy
|
|||||||
const bufIndex = j + bufSize;
|
const bufIndex = j + bufSize;
|
||||||
const data = buffer.slice(j, bufIndex);
|
const data = buffer.slice(j, bufIndex);
|
||||||
|
|
||||||
const width = data[4];
|
const width = TILE_SIZE;
|
||||||
const height = data[5];
|
const height = TILE_SIZE / 2;
|
||||||
|
|
||||||
|
|
||||||
const mousePositionX = Math.floor(tempPoint.x);
|
const mousePositionX = Math.floor(tempPoint.x);
|
||||||
const mousePositionY = Math.floor(tempPoint.y);
|
const mousePositionY = Math.floor(tempPoint.y);
|
||||||
@ -137,12 +136,11 @@ export class FloorplanEditor extends PixiApplicationProxy
|
|||||||
const tileStartX = data[2];
|
const tileStartX = data[2];
|
||||||
const tileStartY = data[3];
|
const tileStartY = data[3];
|
||||||
|
|
||||||
|
|
||||||
const centreX = tileStartX + (width / 2);
|
const centreX = tileStartX + (width / 2);
|
||||||
const centreY = tileStartY + (height / 2);
|
const centreY = tileStartY + (height / 2);
|
||||||
|
|
||||||
const dx = Math.abs(mousePositionX - centreX - 2);
|
const dx = Math.abs(mousePositionX - centreX);
|
||||||
const dy = Math.abs(mousePositionY - centreY - 2);
|
const dy = Math.abs(mousePositionY - centreY);
|
||||||
|
|
||||||
const solution = (dx / (width * 0.5) + dy / (height * 0.5) <= 1);//todo: improve this
|
const solution = (dx / (width * 0.5) + dy / (height * 0.5) <= 1);//todo: improve this
|
||||||
if(solution)
|
if(solution)
|
||||||
@ -171,7 +169,6 @@ export class FloorplanEditor extends PixiApplicationProxy
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private onClick(x: number, y: number): void
|
private onClick(x: number, y: number): void
|
||||||
{
|
{
|
||||||
const tile = this._tilemap[y][x];
|
const tile = this._tilemap[y][x];
|
||||||
|
Loading…
Reference in New Issue
Block a user