Torch animation with particles


  • Forum Admin

    Here a torch animation for the player (torch_idle.bani) with particles, more below. The torch item has been added to all servers.

    {
      "filetype": "bbuilderani",
      "aniversion": 1,
      "copyright": "2019 iAppsBeats LTD",
    
      "options": {
        "looping": 1,
        "continuous": 1,
        "center": [24, 32],
        "blockingbounds": [0,0,32,32],
        "nameoffsety": 45,
        "particleslayer": "drawover",
        "particlescontinueafterdeath": true
      },
    
      "defaults": {
        "BODY":   "bbuilder_clotharmor.png",
        "HEAD":   "bbuilder_head1.png",
        "HAT":    "bbuilder_hat1.png",
        "TORCH":  "bbuilder_torch.png"
      },
    
      "emitters": {
        "1": {
          "relative": false,
          "reduceonmobile": false,
          "quantity": [0,2],
          "limit": 50,
          "draworder": "up",
    
          "particles": [
            {
              "lifetime": [0.9,2],
              "image": "bbuilder_smoke.png",
              "mode": "add",
              "alpha": 1,
              "zoom": 0.2,
              "red": 1,
              "green": 0.25,
              "blue": 0,
              "rotation": [0, 360],
              "spin": [0, 5],
              "zangle": 0,
              "gravity": -80,
    
              "effects": [
                {"type":"range","time":[0.8,2],"attr":"alpha","mode":"replace","value":[1,0.05]},
                {"type":"range","time":[0.05,0.2],"attr":"zoom","mode":"replace","value":[0.2,0.35]},
                {"type":"range","time":[0.8,2],"attr":"zoom","mode":"replace","value":[0.35,0.05]}
              ]
            }
          ]
        }
      },
    
      "sprites": {
         "0": {"gfx":"bbuilder_bomb.png", "bounds": [0,48,48,26]},
         "1": {"gfx":"TORCH", "bounds":[0,0,32,32]},
    
         "20": {"gfx":"HEAD", "bounds": [48,0,48,48]},
         "21": {"gfx":"HEAD", "bounds": [96,0,48,48], "scale":[-1,1]},
         "22": {"gfx":"HEAD", "bounds": [ 0,0,48,48]},
         "23": {"gfx":"HEAD", "bounds": [96,0,48,48]},
    
         "45": {"gfx":"BODY", "bounds": [96, 48,48,48], "scale":[-1,1]},
         "52": {"gfx":"BODY", "bounds": [48,144,48,48]},
         "54": {"gfx":"BODY", "bounds": [ 0,144,48,48]},
         "55": {"gfx":"BODY", "bounds": [96,144,48,48]},
    
         "103": {"gfx":"HEAD", "bounds": [24,48,10,11]},
         "107": {"gfx":"HEAD", "bounds": [ 5,48, 8,10], "scale":[-1,1]},
         "109": {"gfx":"HEAD", "bounds": [24,48,10,11], "scale":[-1,1]},
         "121": {"gfx":"HEAD", "bounds": [65,48,11,10]},
    
         "300": {"gfx":"HAT", "bounds": [48,0,48,72]},
         "301": {"gfx":"HAT", "bounds": [96,0,48,72], "scale":[-1,1]},
         "302": {"gfx":"HAT", "bounds": [ 0,0,48,72]},
         "303": {"gfx":"HAT", "bounds": [96,0,48,72]},
    
         "401": {"gfx":"BOW", "bounds": [0,0,64,96], "rotation": [ 45,24,48]},
         "403": {"gfx":"BOW", "bounds": [0,0,64,96], "rotation": [135,24,48]}
      },
    
      "frames": [
        {
          "directions": [
            [[0,  0, 26], [ 52, 0,  8], [ 20, 0,-15], [103, 7, 26], [107,33, 22], [403,-4,-22], [300, 0,-31], [1, 24,4]],
            [[0,  0, 26], [403, 7,-26], [  1,-7, -2], [ 45, 0,  6], [ 21, 0,-17], [301, 0,-33], [109,24, 27]],
            [[0,  0, 26], [ 54, 0,  8], [ 22, 0,-15], [302, 0,-31], [103, 7, 26], [107,33, 22], [  1,-7,  7]],
            [[0,  0, 26], [401,-7,-26], [ 55, 0,  7], [ 23, 0,-17], [303, 0,-33], [121,24, 27], [  1,17,  7]]
          ],
          "duration": 100,
          "emit": [
            [{"emitter":"1", "position":[40,40, 48]}],
            [{"emitter":"1", "position":[10,22, 48]}],
            [{"emitter":"1", "position":[ 8,45, 48]}],
            [{"emitter":"1", "position":[34,45, 48]}]
          ]
        }
      ]
    }
    

    To get the fire/flame particles, you need to define an emitter and emit the particles either automatically (by defining an "interval") or inside the frames with "emit".

    New options to make this torch possible:

    • options.particleslayer = "drawover" - to let the particles draw over the player (only other choice is "drawunder")
    • options.particlescontinueafterdeath = "true" - to let the particles not disappear immediatelly when the animation is switched to walk or attack
    • emitter.quantity = [0,2] - you can now define a range of number of particles to emit
    • frame.emit = [[upemitters], [leftemitters], [downemitters], [rightemitters]] - define emitters independently for each direction. If you only provide one array then it's working like before, where you just define an array of emitters which work regardless of the current player direction
    • gravity = -80 - using a negative gravity to pull the particles up (you can alternatively also use zangle to move the particles up by a fixed speed)


  • Thank You for explaining some of the script. now i seem to have a better understanding of what does what. =]



  • what modes are available :p?


  • Forum Admin

    @Elk said in Torch animation with particles:

    what modes are available :p?

    add: source SRC_ALPHA, dest ONE
    subtract: source ZERO, dest ONE_MINUS_SRC_ALPHA
    and otherwise default/normal: source SRC_ALPHA, dest ONE_MINUS_SRC_ALPHA


  • Forum Admin

    Here an example of a projectile with fire particles:

    {
      "filetype": "bbuilderani",
      "aniversion": 1,
      "copyright": "2019 iAppsBeats LTD",
    
      "options": {
        "looping": 1
      },
    
      "defaults": {
        "ARROW":  "bbuilder_arrow1.png"
      },
    
      "emitters": {
        "1": {
          "relative": false,
          "reduceonmobile": false,
          "quantity": [0,2],
          "limit": 50,
          "draworder": "up",
    
          "particles": [
            {
              "lifetime": [0.9,2],
              "image": "bbuilder_smoke.png",
              "mode": "add",
              "alpha": 1,
              "zoom": 0.2,
              "red": 1,
              "green": 0.25,
              "blue": 0,
              "rotation": [0, 360],
              "spin": [0, 5],
              "zangle": 0,
              "gravity": -80,
    
              "effects": [
                {"type":"range","time":[0.8,2],"attr":"alpha","mode":"replace","value":[1,0.05]},
                {"type":"range","time":[0.05,0.2],"attr":"zoom","mode":"replace","value":[0.2,0.35]},
                {"type":"range","time":[0.8,2],"attr":"zoom","mode":"replace","value":[0.35,0.05]}
              ]
            }
          ]
        }
      },
    
      "sprites": {
         "0": {"gfx":"bbuilder_arrowshadow.png", "bounds":[0,0,64,16], "rotation":["OBJECT",24,8]},
         "1": {"gfx":"ARROW", "bounds":[0,0,80,16], "rotation":["OBJECT",24,8]}
      },
    
      "frames": [
        {
          "directions": [
            [[0,-24,0], [1,-24,-8]]
          ],
          "duration": 50,
          "emit": [{"emitter":"1", "position":[0, -8, 0]}]
        }
      ]
    }
    

Log in to reply