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

Method onResetEvent

packages/examples/src/examples/text/text.ts:43–208  ·  view source on GitHub ↗
(app: Application)

Source from the content-addressed store, hash-verified

41 */
42export class TextScreen extends Stage {
43 onResetEvent(app: Application) {
44 const w = app.viewport.width;
45
46 app.world.addChild(new ColorLayer("background", "#202020"), 0);
47 app.world.addChild(new BaselineOverlay(w, app.viewport.height), 2);
48
49 // ---- Font size test (left side) ----
50 let yPos = 0;
51 for (let i = 8; i < 56; i += 8) {
52 const t = new Text(5, yPos, {
53 font: "Arial",
54 size: i,
55 fillStyle: "white",
56 strokeStyle: "red",
57 lineWidth: 1,
58 textBaseline: "top",
59 textAlign: "left",
60 text: `Arial Text ${i}px !`,
61 });
62 t.setOpacity(0.5);
63 app.world.addChild(t, 1);
64 yPos += t.getBounds().height;
65 }
66
67 // ---- BitmapText size test (right side) ----
68 yPos = 0;
69 for (let i = 1; i < 5; i++) {
70 const b = new BitmapText(w, yPos, {
71 font: "xolo12",
72 size: i * 0.75,
73 textAlign: "right",
74 textBaseline: "top",
75 text: "BITMAP TEST",
76 });
77 b.fillStyle.parseCSS("indigo");
78 for (let j = 0; j < i; j++) {
79 b.fillStyle.lighten(0.25);
80 }
81 app.world.addChild(b, 1);
82 yPos += b.getBounds().height * 1.5;
83 }
84
85 // ---- Font baseline test (y=200) ----
86 const baselines = [
87 "bottom",
88 "ideographic",
89 "alphabetic",
90 "middle",
91 "hanging",
92 "top",
93 ];
94 let xPos = 0;
95
96 // we need a temp Text to measure widths for spacing
97 const tmpFont = new Text(0, 0, {
98 font: "Arial",
99 size: 16,
100 fillStyle: "white",

Callers

nothing calls this directly

Calls 11

setTextMethod · 0.95
measureTextMethod · 0.95
setTextMethod · 0.95
measureTextMethod · 0.95
addChildMethod · 0.80
parseCSSMethod · 0.80
lightenMethod · 0.80
startMethod · 0.80
toMethod · 0.80
getBoundsMethod · 0.65
setOpacityMethod · 0.45

Tested by

no test coverage detected