-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
isolating transformations into a dedicated class
- Loading branch information
1 parent
b4c5647
commit a7a46ea
Showing
7 changed files
with
73 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Point } from 'plugin.model'; | ||
|
||
class SelectionUtilClass { | ||
private game: Phaser.Game; | ||
private selectionArea: HTMLElement; | ||
|
||
public init(game: Phaser.Game, selectionArea: HTMLElement) { | ||
this.game = game; | ||
this.selectionArea = selectionArea; | ||
} | ||
|
||
public pointFromAreaToGame(x: number, y: number, out: Point) { | ||
out.x = this.game.width * x / this.selectionArea.clientWidth; | ||
out.y = this.game.height * y / this.selectionArea.clientHeight; | ||
} | ||
} | ||
|
||
export const SelectionUtil = new SelectionUtilClass(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,21 @@ | ||
import './selection.scss'; | ||
|
||
export class NewSelection extends HTMLElement { | ||
connectedCallback() { | ||
private _object: PIXI.DisplayObject; | ||
|
||
public init() { | ||
this.classList.add('selector'); | ||
} | ||
|
||
public set object(obj: PIXI.DisplayObject) { | ||
if (!obj) { | ||
this._object = null; | ||
this.style.display = 'none'; | ||
return; | ||
} | ||
console.log(obj.name); | ||
this.style.display = 'block'; | ||
} | ||
} | ||
|
||
customElements.define('phred-selection', NewSelection); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters