Skip to content
Nicholas Bates edited this page May 9, 2018 · 3 revisions

All ships should have one or more particle emitters defined to enhance their behaviour, be it by shooting flames out of the engine, or many other possibilities that are really only limited by your imagination.

Attributes

The following attributes should be defined in a new object within your ships shipName.json, under the "particleEmitters" array:

  • "position": String "x y". This is used to specify where the particles from the emitter originate from. You can find the normalized positions by dividing the x coordinate of the pixel you choose by the width of the texture and the y coordinate by the height. Example: "position": "0.1 0.2"
  • "trigger": String. This is used to specify when the particle should be toggled. More information about triggers can be found below. Example: "trigger": "engine"
  • "angleOffset": Optional Number angle. This is used to specify the offset angle at which the particles should shoot, based on the ships current heading. Example: "angleOffset": 90
  • "hasLight": Boolean. This is used to specify whether or not the particle emitter has a light at the origin. Example: "hasLight": true
  • "particle": Object. Defines the physical properties of the particle emitter. These attributes must be included:
    • "effectFile": String. A fully qualified effect name. Example: "effectFile": "core:flame"
    • "size" Number. The size of the particles to be emitted. Example "size": 0.07
    • "tex"String. A fully qualified texture name. Example: "tex": "core:fire"
    • "tint" String. An HSB colour to specify the tint of the light source. Example "tint": "hsb 140 20 65"
  • workSounds: Optional Array sounds. The sounds to be played when the particle emitter is fired. Example: [ core:medEngineWork0" ]

These attributes build to create an array of objects like as follows, which defines two particle emitters:

"particleEmitters": [
    {
        "position": "0.11 0.43",
        "trigger": "engine",
        "hasLight": true,
        "particle": {
            "effectFile": "core:flame",
            "size": 0.07,
            "tex": "core:fire",
            "tint": "hsb 140 20 65"
        },
        "workSounds": [
            "core:medEngineWork0",
            "core:medEngineWork1",
            "core:medEngineWork2",
            "core:medEngineWork3",
            "core:medEngineWork4"
        ]
    },
    {
        "position": "0.11 0.57",
        "trigger": "engine",
        "hasLight": true,
        "particle": {
            "effectFile": "core:flame",
            "size": 0.07,
            "tex": "core:fire",
            "tint": "hsb 140 20 65"
        },
        "workSounds": [
            "core:medEngineWork0",
            "core:medEngineWork1",
            "core:medEngineWork2",
            "core:medEngineWork3",
            "core:medEngineWork4"
        ]
    }
]

Triggers

Currently there are four particle emitter triggers built into the game:

  • none: Particles are always emitted.
  • engine: Particles are emitted whilst the ship engine is running.
  • collision: Particles are emitted whilst the ship is colliding with an object.
  • shoot: Particles are emitted whilst the ship is firing its weapon.

If you want to use a trigger that has not been implemented, you simply need to call game.getPartMan().updateAllHullEmittersOfType(hull, "yourTrigger", true/false); each frame within your update() method.