मुख्य सामग्री पर जाएँ
Skillpedia
सामान्य कोडिंग6.4k · #14217

melonjs-ui-and-text

यह क्या करती है

यह बताती है कि melonJS गेम में HUD तत्व, बटन, मेनू, पैनल और टेक्स्ट कैसे जोड़ें। यह मेनू, स्कोर और इंटरफ़ेस तत्व बनाने वाले गेम डेवलपर्स के लिए है।

कब इस्तेमाल करें

  • ✓जब डेवलपर चाहे कि गेम स्क्रीन पर क्लिक करने योग्य बटन या मेनू हो।
  • ✓जब डेवलपर चाहे कि गेम में हेल्थ बार या प्रगति बार हो।
  • ✓जब डेवलपर का आउटलाइन वाला टेक्स्ट कटा हुआ या बहुत पतला दिखे।

Skill का लिंक

https://github.com/melonjs/melonJS/blob/master/packages/melonjs/skills/melonjs-ui-and-text/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/melonjs/melonJS/blob/master/packages/melonjs/skills/melonjs-ui-and-text/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“मेरे melonJS मेनू स्क्रीन में एक स्कोर डिस्प्ले और एक क्लिक करने योग्य स्टार्ट बटन जोड़िए।”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

यह स्किल टेक्स्ट, बटन, स्लाइडर और पैनल बनाना, और उन्हें एक ऐसी स्क्रीन पर रखना दिखाती है जो गेम दुनिया हिलने पर भी स्थिर रहती है।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।

UI, HUD and text

Outlined text: behind the glyphs, or over them

An outline is centred on the glyph's edge, so half of it lies inside the glyph. Text paints it behind the glyphs by default (paintOrder: "stroke"): the letters stay whole and the outline shows only around them, so a thick outline works on any face. What shows is half of lineWidth: ask for twice the width you want to see.

paintOrder: "fill" paints the glyphs first and the outline over them, as a plain canvas does with fillText then strokeText, and as melonJS did before 20.13. Its inner half then covers the letters: on a small or thin face a lineWidth of 3 already leaves them solid outline colour.

const style = {
    font: "sans-serif", size: 32,
    fillStyle: "#ffd23f", strokeStyle: "#1b1b1b", lineWidth: 6,
};
new Text(x, y, { ...style, text: "BEHIND" });                     // the default
new Text(x, y, { ...style, paintOrder: "fill", text: "OVER" });   // the old look

The stroke used to cost you the top row of pixels as well, and a display face whose glyphs overshoot the nominal ascent did the same on its own: the render box was sized from the line height alone, with no allowance for either. That is fixed — the bake is padded by the ink's real extent and the blit shifts back by the same amount, so nothing is clipped and the reported bounds are unchanged. Write the string you mean:

new Text(x, y, { font: "Display", lineWidth: 1, lineHeight: 1.45, text: "" });
hud.setText("SCORE 100");

If you have a label carrying a leading \n to buy headroom, that workaround is now dead weight — drop it, and take the line height back off the position you shifted it by.

The outline's corners are set by lineJoin, the same property a canvas context has, and miterLimit:

setting corners use it for
lineJoin: "round" (default) rounded: the outline is the same width all around almost everything: HUDs, buttons, titles
lineJoin: "bevel" cut flat a harder edge with no spikes
lineJoin: "miter" pointed, as a plain canvas strokes text a sharp, angular look
miterLimit: n (default 10) with "miter" only: a corner pointing further than n half line widths is cut flat instead taming the spikes "miter" grows on "A", "V", "M"

At the canvas default of 10, a thick "miter" outline grows spikes several times its width from sharp glyphs; 2 to 4 keeps the corners pointed and the spikes short:

const outline = {
    font: "sans-serif", size: 48,
    fillStyle: "#ffffff", strokeStyle: "#000000", lineWidth: 6,
};
new Text(x, y, { ...outline, text: "ROUND" });                    // the default
new Text(x, y, { ...outline, lineJoin: "bevel", text: "BEVEL" });
new Text(x, y, { ...outline, lineJoin: "miter", text: "MITER" }); // long spikes
new Text(x, y, { ...outline, lineJoin: "miter", miterLimit: 3, text: "MITER 3" });

Whichever you pick, the bake leaves room for it on all four sides, so no corner is cut and the label's position and bounds do not move; pointed corners just cost a bigger texture. Changed on a live label, they show from the next setText().

Gradient text

fillStyle takes a Gradient as well as a colour — the same object Renderer#setColor accepts, built the way the canvas API builds one:

const ramp = renderer.createLinearGradient(0, 0, 0, 24);  // top to bottom
ramp.addColorStop(0, "#fffdf0");
ramp.addColorStop(1, "#f0a020");

new Text(x, y, { font: "Display", size: 24, fillStyle: ramp });

Coordinates are the label's own bake: (0, 0) is the top-left of the render box, so the ramp above runs down one line. A multi-line label restarts it on every line, reading like one Text per line — you do not have to author the gradient over the block height. Pass gradientPerLine: false for a single ramp spanning the whole block, which is what a plain canvas does and what a deliberate fade across a two-line title wants.

The ramp colours the fill only — Text strokes in a separate pass, so an outline keeps its own colour without any luminance trickery — and it works on Canvas2D, which a post effect does not.

The gradient does not live in fillStyle

fillStyle ACCEPTS a Gradient; it never HOLDS one. The constructor routes it to fillGradient and leaves fillStyle as the pooled Color it always is, which is what keeps fillStyle.alpha gating the fill and keeps the colour owned by the pool.

So changing the ramp la

अक्सर पूछे जाने वाले सवाल

मेरा आउटलाइन टेक्स्ट गलत क्यों दिखता है?

स्किल समझाती है कि आउटलाइन अक्षर के किनारे पर केंद्रित होता है, इसलिए चौड़ाई का केवल आधा हिस्सा दिखता है।

दो तत्व ओवरलैप हों तो क्लिक किसे मिलता है?

स्किल कहती है कि ओवरलैप वाले पैनल में pointer इनमें से किसी एक को जाता है, और वह समझाती है कि उसे कैसे सँभालें।

क्या मैं कस्टम वेब फ़ॉन्ट इस्तेमाल कर सकता हूँ?

हाँ। स्किल टेक्स्ट तत्वों के लिए वेब फ़ॉन्ट लोड करने का ज़िक्र करती है।

जानकारी

लेखक का मूल विवरण

Use this skill for HUDs, buttons, menus, options screens, dialogue panels, progress bars and on-screen text in melonJS. Covers UIBaseElement/UISpriteElement/UITextButton, UICheckbox, UISlider, ProgressBar, UIPanel (skins, layout, scrolling), Draggable and DropTarget, the floating screen-space container pattern, which of two overlapping panels gets the pointer, Text and BitmapText, web font loading, and NineSliceSprite panels. Triggers on: UI, HUD, button, checkbox, radio button, UICheckbox, slider, UISlider, volume slider, options menu, settings screen, scrolling list, scroll panel, layout, co

repo: melonjs/melonJS

लोकप्रियता

GitHub स्टार
6.4k
रैंकिंग में स्थान
#14217
लाइसेंस
MIT
अपडेट की गई
2/11/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

melonjs-20-migration

6.4k

आपके एजेंट को melonJS वर्शन 20 के लिए गेम कोड लिखने में मदद करती है और पुराने वर्शन के आउटडेटेड तरीकों से बचाती है, जैसे ज़रूरी async स्टार्टअप।

कोडिंगसामान्य कोडिंग

melonjs-3d-assets

6.4k

आपके एजेंट को glTF, GLB और OBJ जैसे 3D मॉडल melonJS ब्राउज़र गेम में लोड करने में मदद करती है, scale और lighting विकल्पों के साथ।

कोडिंगसामान्य कोडिंग

melonjs-3d

6.4k

आपके एजेंट को melonJS ब्राउज़र गेम में 3D या 2.5D दृश्य बनाने में मदद करती है, जिसमें कैमरा, मेश, लाइट और गहराई शामिल हैं, इंजन के अपने axis नियमों के साथ।

कोडिंगसामान्य कोडिंग

melonjs-audio

6.4k

आपके एजेंट को melonJS गेम में साउंड इफ़ेक्ट और संगीत जोड़ने में मदद करती है, जिसमें ऑडियो सेटअप, बैकग्राउंड ट्रैक, वॉल्यूम नियंत्रण और स्थानिक ध्वनि शामिल हैं।

कोडिंगसामान्य कोडिंग

मिलती-जुलती skills