melonjs-particles-and-trails
ما الذي تفعله
تشرح هذه المهارة كيفية إعداد باعثات الجسيمات والآثار في melonJS، بما في ذلك التأثيرات المفاجئة والمستمرة. وهي موجهة لمطوّري الألعاب الذين يضيفون تأثيرات بصرية مثل الانفجارات أو العادم.
متى تستخدمها
- ✓عندما يريد مطوّر تأثير شرر أو انفجار في لعبة melonJS.
- ✓عندما يضيف مطوّر باعث جسيمات ولا يظهر شيء على الشاشة.
- ✓عندما يريد مطوّر أثراً حركياً خلف جسم متحرك.
رابط المهارة
https://github.com/melonjs/melonJS/blob/master/packages/melonjs/skills/melonjs-particles-and-trails/SKILL.mdانسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.
طريقة الاستخدام
أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.
رسالة جاهزة للصق
لـ Claude Code أو Codex أو Cursor: شغّله داخل مجلد مشروعك وستُثبَّت المهارة.
نزّل ملف SKILL.md وضعه في مجلد مهارات وكيلك.
مثال على ما تطلبه من الذكاء الاصطناعي
“أضف انفجار شرر إلى لعبتي عندما يصطدم اللاعب بالجدار، وتأكد من أنه يظهر فعلاً.”
5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.
كيف تعمل
تشرح هذه المهارة أن الباعث يجب أن يُخبَر بأن يبدأ الإصدار، إما بانفجار مفاجئ أو بتدفق مستمر. وتغطي أيضاً إعدادات السرعة والعمر والعدد.
المحتوى التقني (ملف SKILL.md الأصلي)
النص الأصلي من المؤلف، مباشرة من GitHub.
Particles and trails
An emitter does nothing until you tell it to emit
Adding a ParticleEmitter to the world is not enough. Nothing appears, and
nothing warns you.
const emitter = new ParticleEmitter(x, y, {
image: loader.getImage("spark"),
totalParticles: 60,
speed: 4,
minLife: 200, maxLife: 800,
});
world.addChild(emitter);
emitter.streamParticles(); // continuous — or:
emitter.burstParticles(); // one shot
streamParticles(ms) takes an optional run time; without one it uses the
duration setting, which defaults to Infinity — a stream runs until
stopStream(). burstParticles(n) launches n, or totalParticles.
Without an image, particles are white squares of textureSize pixels (8 by
default), coloured by tint. Every such emitter draws the renderer's one
shared white pixel, stretched, so an emitter per explosion or a reset() on
every tweak costs no texture.
Tuning an effect: the Particle Editor
Settings are easier to find by eye than by reasoning. The
Particle Editor
runs one emitter live, with every setting on a slider, from a preset (fire,
smoke, rain, explosions, 3D bursts and rings…), a built-in texture or a sprite
(sheet) of your own, under a 2D camera or an orbiting 3D one. It writes out the
matching new ParticleEmitter(...) call, listing only what differs from the
defaults, and the same settings as JSON, in the emitter's own units, to load at
run time:
// preloaded with { name: "smoke-fx", type: "json", src: "data/fx/smoke.json" }
const effect = loader.getJSON("smoke-fx");
const emitter = new ParticleEmitter(x, y, {
...effect.settings,
// no `image` for the plain square: `getImage` would give null
...(effect.image ? { image: loader.getImage(effect.image) } : {}),
});
Point a user there when they are tuning numbers by trial and error.
It covers every setting that changes how one emitter looks, but not:
- Layered effects. It shows one emitter at a time. A campfire (flames,
sparks, smoke) or an explosion (flash, debris, smoke) is several emitters
at the same spot: tune each in the editor, then add them side by side,
the one drawn on top last (or with a higher
z). - Trails.
TrailandTrail3dare separate renderables; see below. - Code-only settings.
onComplete,autoDestroyOnComplete,accurateBounds, and aContainerasreferenceSpace(it offers"local"and"world").textureAdditiveis left out:blendModereplaces it. - Changes at run time. Calling
burstParticles()when something happens, or assigningemitter.blendModewhile particles are alive, is game code. Its "moving emitter" option previews the common case: an emitter attached to something that moves.
Sprite-sheet particles
Use framewidth and frameheight (the same names as on Sprite) to divide
image into a regular grid. Each omitted dimension defaults to that of the
image. Frames are numbered from zero left-to-right, then top-to-bottom; only
whole cells count, so partial cells along the right/bottom edges are ignored.
Margins and spacing are not supported.
const explosion = new ParticleEmitter(x, y, {
image: loader.getImage("explosion-sheet"),
framewidth: 32, frameheight: 32,
frames: [0, 1, 2, 3],
minLife: 400, maxLife: 800,
});
world.addChild(explosion);
explosion.burstParticles();
Omit frames to use every cell. Each particle traverses the sequence once
over its own lifetime, with equal time for each entry; repeated indices hold
a frame longer. Existing scale, opacity and rotation still apply. Bounds and
the rotation pivot use one frame's dimensions, rather than the whole sheet.
Set randomFrame: true for debris: a particle chooses one entry at birth and
keeps it until it dies. Different frames share the same image and GPU batch.
Without sheet settings, particles still draw the whole image as before, and
that includes randomFrame on its own: it needs a grid to choose from, so
pair it with framewidth/frameheight or it does nothing.
Note the variety is in SHAPE, not colour. tint belongs to the emitter, so
every particle from one emitter is tinted alike however many frames it picks
between. For a colour that changes over each particle's life, use
tintOverLife (below) rather than drawing one frame per colour.
Frame dimensions must be positive integers that fit inside the image, and an ex
الأسئلة الشائعة
لماذا لا يُظهر الباعث شيئاً؟
تقول المهارة إن إضافة الباعث وحدها لا تكفي، بل يجب استدعاء دالة الانفجار أو التدفق.
هل أستطيع استخدام صورتي الخاصة؟
نعم. بدون صورة تكون الجسيمات مربعات صغيرة ملونة.
هل يوجد أداة مرئية للضبط؟
نعم. تذكر المهارة Particle Editor الذي يكتب كود الإعداد المطابق.
التفاصيل
الوصف الأصلي من المؤلف
Use this skill for particle effects and motion trails in melonJS — ParticleEmitter configuration, burst versus stream emission, the referenceSpace frame of reference introduced in 20.2, 3D particle motion through elevation and minSpread/maxSpread in 20.8, and the Trail renderable. Covers the emitter that silently does nothing until you call an emit method. Triggers on: Trail3d, ribbon, exhaust trail, speed streak, ski track, tyre mark, ribbonNormal, ParticleEmitter, particles, particle editor, tune particles, spawn depth, volume, burstParticles, streamParticles, referenceSpace, ParticleEmitter
repo: melonjs/melonJS
الشعبية
- نجوم GitHub
- 6.4k
- الترتيب
- #14208
- الترخيص
- MIT
- آخر تحديث
- 2/11/2026
التعليقات
- …
المزيد من المهارات من هذا المستودع
melonjs-20-migration
6.4kيساعد وكيلك على كتابة كود لعبة melonJS للإصدار 20 وتجنب الدوال القديمة من الإصدارات السابقة، مثل بدء التشغيل غير المتزامن المطلوب.
melonjs-3d-assets
6.4kيساعد وكيلك على تحميل نماذج ثلاثية الأبعاد مثل glTF وGLB وOBJ في لعبة melonJS للمتصفح، مع خيارات المقياس والإضاءة.
melonjs-3d
6.4kيساعد وكيلك على بناء مشاهد ثلاثية الأبعاد وشبه ثلاثية في melonJS، مع الكاميرات والأضواء والعمق وفق قواعد المحور الخاصة بالمحرك.
melonjs-audio
6.4kيساعد وكيلك على إضافة المؤثرات الصوتية والموسيقى إلى لعبة melonJS، بما في ذلك إعداد الصوت والمقاطع الخلفية والتحكم في الصوت والصوت المكاني.
مهارات مشابهة
diffs
394kيتيح لوكيلك إنتاج فرق تعديلات حقيقي يمكن مشاركته، كرابط عرض أو ملف صورة، بدلاً من ملخص مكتوب يدوياً.
coding-agent
394kيساعد وكيلك على تسليم مهمة برمجة كبيرة إلى Codex أو Claude Code أو OpenCode كعامل في الخلفية، ثم متابعة تقدمها.
gh-issues
394kيساعد وكيلك على إيجاد مشكلات GitHub واختيار ما ستعمل عليه، وفتح طلبات سحب بالإصلاحات، ومتابعة تعليقات المراجعة.