MCPcopy Create free account
hub / github.com/melonjs/melonJS / constructor

Method constructor

packages/examples/src/examples/isometricRpg/play.ts:9–49  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7
8class Selector extends Renderable {
9 constructor() {
10 // reference to the main layer
11 const levelLayer = game.world.getChildByName("level 1")[0];
12
13 // call the parent constructor using the tile size
14 super(0, 0, levelLayer.tilewidth / 2, levelLayer.tileheight);
15
16 this.refLayer = levelLayer;
17
18 this.anchorPoint.set(0, 0);
19
20 // configure it as floating
21 this.floating = true;
22
23 // create a corresponding diamond polygon shape with an isometric projection
24 this.diamondShape = this.clone().toPolygon().toIso();
25
26 // currently selected tile
27 this.currentTile = null;
28
29 // simple system font to display tile coordinates
30 this.font = new Text(0, 0, {
31 font: "Arial",
32 fillStyle: "#FFFFFF",
33 size: 10,
34 textAlign: "center",
35 });
36
37 // dirty flag to enable/disable redraw
38 this.dirty = false;
39
40 this.isKinematic = false;
41
42 // subscribe to pointer and viewport move event
43 this.pointerEvent = event.on(event.POINTERMOVE, this.pointerMove, this);
44 this.viewportEvent = event.on(
45 event.VIEWPORT_ONCHANGE,
46 this.viewportMove,
47 this,
48 );
49 }
50
51 /** pointer move event callback */
52 pointerMove(event) {

Callers

nothing calls this directly

Calls 6

getChildByNameMethod · 0.80
onMethod · 0.80
cloneMethod · 0.65
setMethod · 0.45
toIsoMethod · 0.45
toPolygonMethod · 0.45

Tested by

no test coverage detected