From 5c8f39ec1ef06304ab8a6a6f20ab4332db72182d Mon Sep 17 00:00:00 2001 From: Bill Date: Wed, 19 Jul 2023 21:57:35 -0400 Subject: [PATCH] Pixi v7 works --- src/nitro/Nitro.ts | 1 - src/nitro/room/object/logic/room/RoomLogic.ts | 12 ------------ src/room/renderer/RoomSpriteCanvas.ts | 2 +- src/room/renderer/utils/ExtendedSprite.ts | 18 ++++++++---------- 4 files changed, 9 insertions(+), 24 deletions(-) diff --git a/src/nitro/Nitro.ts b/src/nitro/Nitro.ts index b77b5d16..735b5dd6 100644 --- a/src/nitro/Nitro.ts +++ b/src/nitro/Nitro.ts @@ -63,7 +63,6 @@ export class Nitro implements INitro autoDensity: false, width: window.innerWidth, height: window.innerHeight, - resolution: window.devicePixelRatio, view: canvas }); } diff --git a/src/nitro/room/object/logic/room/RoomLogic.ts b/src/nitro/room/object/logic/room/RoomLogic.ts index 4e7a9672..610957d7 100644 --- a/src/nitro/room/object/logic/room/RoomLogic.ts +++ b/src/nitro/room/object/logic/room/RoomLogic.ts @@ -396,12 +396,6 @@ export class RoomLogic extends RoomObjectLogicBase if(((((planePosition.x >= 0) && (planePosition.x < leftSideLength)) && (planePosition.y >= 0)) && (planePosition.y < rightSideLength))) { - console.log('found plane', ` - tileX: ${ tileX } - tileY: ${ tileY } - tileZ: ${ tileZ } - leftSideLength: ${ leftSideLength } - rightSideLength: ${ rightSideLength }`); this.object.model.setValue(RoomObjectVariable.ROOM_SELECTED_X, tileX); this.object.model.setValue(RoomObjectVariable.ROOM_SELECTED_Y, tileY); this.object.model.setValue(RoomObjectVariable.ROOM_SELECTED_Z, tileZ); @@ -409,12 +403,6 @@ export class RoomLogic extends RoomObjectLogicBase } else { - console.log('no found plane', ` - tileX: ${ tileX } - tileY: ${ tileY } - tileZ: ${ tileZ } - leftSideLength: ${ leftSideLength } - rightSideLength: ${ rightSideLength }`); this.object.model.setValue(RoomObjectVariable.ROOM_SELECTED_PLANE, 0); return; diff --git a/src/room/renderer/RoomSpriteCanvas.ts b/src/room/renderer/RoomSpriteCanvas.ts index b2989176..4cc4283d 100644 --- a/src/room/renderer/RoomSpriteCanvas.ts +++ b/src/room/renderer/RoomSpriteCanvas.ts @@ -829,7 +829,7 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas { const extendedSprite = this.getExtendedSprite(spriteId); - if(extendedSprite && extendedSprite.containsPoint(new Point((x - extendedSprite.x), (y - extendedSprite.y)))) + if(extendedSprite && extendedSprite.containsPixelPerfectPoint(new Point((x - extendedSprite.x), (y - extendedSprite.y)))) { if(extendedSprite.clickHandling && ((type === MouseEventType.MOUSE_CLICK) || (type === MouseEventType.DOUBLE_CLICK))) { diff --git a/src/room/renderer/utils/ExtendedSprite.ts b/src/room/renderer/utils/ExtendedSprite.ts index 36392f38..8ac9c57e 100644 --- a/src/room/renderer/utils/ExtendedSprite.ts +++ b/src/room/renderer/utils/ExtendedSprite.ts @@ -65,26 +65,24 @@ export class ExtendedSprite extends Sprite public containsPoint(point: Point): boolean { - return ExtendedSprite.containsPoint(this, point); + return this.containsPixelPerfectPoint(point); } - public static containsPoint(sprite: ExtendedSprite, point: Point): boolean + public containsPixelPerfectPoint(point: Point): boolean { - if(!sprite || !point || (sprite.alphaTolerance > 255)) return false; + if(!point || (this.alphaTolerance > 255)) return false; - if(!(sprite instanceof Sprite)) return false; + if((this.texture === Texture.EMPTY) || (this.blendMode !== BLEND_MODES.NORMAL)) return; - if((sprite.texture === Texture.EMPTY) || (sprite.blendMode !== BLEND_MODES.NORMAL)) return; - - const texture = sprite.texture; + const texture = this.texture; const baseTexture = texture.baseTexture; if(!texture || !baseTexture || !baseTexture.valid) return false; - const x = (point.x * sprite.scale.x); - const y = (point.y * sprite.scale.y); + const x = (point.x * this.scale.x); + const y = (point.y * this.scale.y); - if(!sprite.getLocalBounds().contains(x, y)) return false; + if(!this.getLocalBounds().contains(x, y)) return false; //@ts-ignore if(!baseTexture.hitMap)