Firework

Learn here how to create and use plugins.

Moderator: Plugin Moderators

User avatar
Josh
Graphic designer
Reactions:
Posts: 2212
Joined: Sat Mar 11, 2017 19:20
Location: The Netherlands
Plugins: Show
Version: Beta
Phone model: Iphone 7

Platform

Plugin Creator

Firework

#1

Post by Josh » Mon Jan 08, 2018 1:51

In this tutorial, I'm going to show how to make firework. You don't need any graphics since the particles are defined in code.

Code: Select all

[
  {
    "id":"$firework30","type":"animation","frames":[{"steal":"$anim_firework00","frame":2}],
    "meta":{"tags":{"firework":{
      "alpha":0.5, 
      "speed":15,
      "speed variation":0,
      "n":1,
      "time":2500,
      "time variation":0,
      "next":[
          {"id":"$firework31",  "always":true}, 
          {"id":"$firework32"}
       ]
    }}}
  },
  {
    "id":"$firework31","type":"animation","frames":[{"steal":"$anim_firework00","frame":2}],
    "meta":{"tags":{"firework":{
      "alpha":100, 
      "speed":5,
      "speed variation":1,
      "n":1000,
      "time":750,
      "time variation":1
    }}}
  },
  {
    "id":"$firework32","type":"animation","frames":[{"steal":"$anim_firework00","frame":3}],
    "meta":{"tags":{"firework":{
      "alpha":100, 
      "speed":5,
      "speed variation":1,
      "n":1000,
      "time":750,
      "time variation":1
    }}}
  },
  {
    "id":"$syl_spawner03",
    "type":"decoration",
    "category":"$category_firework00",
    "title":"Willow",
    "text":"A big willow.",
    "width":1,
    "height":1,
    "frames":[{"x":960,"y":524,"w":32,"h":20,"offset x":1024,"offset y":1024}],
    "on click fun":[
      {
        "actions":[{"type":"firework","id":"$firework30","z":1}]
      }
    ],
    "fun":[
      {
        "condition":{"type":"or","inner":[
          {"type":"building","id":"$on","x":1},
          {"type":"building","id":"$on","y":1},
          {"type":"building","id":"$on","x":-1},
          {"type":"building","id":"$on","y":-1}
        ]},
        "actions":[{"type":"firework","id":"$firework30","z":1}]
      }
    ],
    "requirements":[{"type":"FEATURE","id":"$feature_firework00"}]
  }
]
The frames are from this picture called $anim_firework00, from left to right (0-14) :img
$anim_firework00.png
$anim_firework00.png (660 Bytes) Viewed 1370 times
The whole code for the huge willow. Let's go through it!

"alpha" - The direction of the particle(s).
"speed" - The speed of a particle(s).
"speed variation" - If there should be variation in speed of the particle(s).
"n" - The number of particles to spawn.
"time" - The duration of the particle(s).
"time variation" - If there should be variation in the duration of the particle(s).
"next" - The id of the particle(s) that should spawn after the lifetime of the current particle(s) expired.

Feel free to ask questions about it :)
Proud TheoTown player sinds update 1.1.50

Creator of Aldorria, Covinton Empire, West Country, Sunnydale

Save nature, before it kills you🌲

User avatar
Lobby
Developer
Reactions:
Posts: 3384
Joined: Sun Oct 26, 2008 12:34
Plugins: Show
Version: Beta
Phone model: S7 edge

Platform

Re: Firework

#2

Post by Lobby » Fri Jan 19, 2018 12:36

Cool, thank you :)
So firework is basically a description of how to spawn particles and what to do when they're at the end of their life time (e.g. spawning new ones).
...Have a nice stay

User avatar
Josh
Graphic designer
Reactions:
Posts: 2212
Joined: Sat Mar 11, 2017 19:20
Location: The Netherlands
Plugins: Show
Version: Beta
Phone model: Iphone 7

Platform

Plugin Creator

Re: Firework

#3

Post by Josh » Fri Jan 26, 2018 2:13

I forgot to mension about the frames, added it :bc
Proud TheoTown player sinds update 1.1.50

Creator of Aldorria, Covinton Empire, West Country, Sunnydale

Save nature, before it kills you🌲

User avatar
Lakan Haraya
Townsman
Reactions:
Posts: 45
Joined: Thu Mar 28, 2019 9:34
Location: Manila, Philippines
Plugins: Show
Version: Beta

Plugin Creator

Platform

Re: Firework

#4

Post by Lakan Haraya » Sun Jul 21, 2019 17:34

@Josh

Please give us more details about those attributes :/ like these following:
How integers on alpha translate on cardinal directions, if it is?
And those variation thingy?

I wonder how...
My fireworks explode immediately on ground and all particles spreads out to the entire city's cake •_• and... beyond :/
Ako ang iyong Haráya
I am your Imagination

Founder of the first rebuilder-manufacturer of passenger-type jeepneys in TheoTown history.

Member of
TPC
“TheoTown Philippines Corporation”

Post Reply Previous topicNext topic

Return to “Tutorials and Documentation”

Who is online

Users browsing this forum: No registered users and 1 guest