Skip to content

Commit

Permalink
Fixes hit area for containers. #284
Browse files Browse the repository at this point in the history
  • Loading branch information
PhaserEditor2D committed May 23, 2023
1 parent fa1ef52 commit e3ca106
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Binary file added design/logo-icons/gumroad-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ namespace phasereditor2d.scene.ui.sceneobjects {

const obj = comp.getObject() as Sprite;

const { displayOriginX, displayOriginY } = obj.getEditorSupport().computeDisplayOrigin();
const { displayOriginX, displayOriginY } = this.getDisplayOrigin(obj);

const tx = obj.getWorldTransformMatrix();

Expand Down Expand Up @@ -366,7 +366,7 @@ namespace phasereditor2d.scene.ui.sceneobjects {

sprite.getWorldTransformMatrix().applyInverse(newPoint.x, newPoint.y, newPoint);

const {displayOriginX, displayOriginY} = sprite.getEditorSupport().computeDisplayOrigin();
let { displayOriginX, displayOriginY } = this.getDisplayOrigin(sprite);

point.x = newPoint.x + displayOriginX;
point.y = newPoint.y + displayOriginY;
Expand All @@ -376,6 +376,16 @@ namespace phasereditor2d.scene.ui.sceneobjects {
args.editor.updateInspectorViewSection(PolygonHitAreaSection.ID);
}

private getDisplayOrigin(sprite: ISceneGameObject) {

if (sprite instanceof Container) {

return { displayOriginX: 0, displayOriginY: 0 };
}

return sprite.getEditorSupport().computeDisplayOrigin();
}

onStopDrag(args: editor.tools.ISceneToolDragEventArgs): void {

this._newPoint = undefined;
Expand Down

0 comments on commit e3ca106

Please sign in to comment.