Page 1 of 1

How to use animation

Posted: 04 Aug 2022, 00:39
by Thiên Ân
Help me with the windturbine fan how can i add it in json?

Re: Advanced tags for building plugins

Posted: 04 Aug 2022, 08:57
by Thiên Ân
How to make the fan of wind turbine rotate?

Re: Advanced tags for building plugins

Posted: 04 Aug 2022, 10:49
by Lobby
Here's part of the definition for the in-game wind turbine:

Code: Select all    Reset

[ { "id":"$animationfan00", "type":"animation", "frames":[{"bmp":"blades.png","w":60,"h":58,"count":6}] }, { "id":"$windturbine00", "type":"energy", "width":3, "height":3, "frames":[{"x":1792,"y":1264,"w":96,"h":96}], "animation":[ {"id":"2x2l", "x":67, "y":-2}, // Some light for night mode {"id":"$animationblinkingredlight3x3","x":23,"y":-71}, // A blinking red light for decoration {"id":"$animationfan00","x":7,"y":-94} // Our previously defined blades ], // ... } ]
JSON checker
Check
The blades:
blades.png
blades.png (5.13 KiB) Viewed 4199 times

Re: Advanced tags for building plugins

Posted: 04 Aug 2022, 17:18
by Thiên Ân
I have written json like that but it doesn't work. Can you explain why you use w, h in both frame and count in animation?

Re: Advanced tags for building plugins

Posted: 04 Aug 2022, 17:49
by Lobby
"doesn't work" is not exactly helpful for us to diagnose the issue.

In the animation I specify width and height explictily so that the game knows the size of a single frame. It then uses count to extract that amount of frames. These will then be used to play the animation.

Re: Advanced tags for building plugins

Posted: 04 Aug 2022, 19:06
by Thiên Ân
I saw some pluggin didnt use w and h. How do you know w h of a plugin

Re: Advanced tags for building plugins

Posted: 05 Aug 2022, 08:04
by Thiên Ân
Lobby wrote: 04 Aug 2022, 17:49 "doesn't work" is not exactly helpful for us to diagnose the issue.

In the animation I specify width and height explictily so that the game knows the size of a single frame. It then uses count to extract that amount of frames. These will then be used to play the animation.
Oke i have done it. How do you know that is the perfect w and h to display each blades of the blades frame and why the game doesn't display all 6 blades if i use this code.

Re: How to use animation

Posted: 05 Aug 2022, 09:49
by Lobby
I made the graphics so that each subframe has this size. It should display all of the 6 frames with this code as it does in the game.

Re: How to use animation

Posted: 05 Aug 2022, 18:20
by Thiên Ân
Lobby wrote: 05 Aug 2022, 09:49 I made the graphics so that each subframe has this size. It should display all of the 6 frames with this code as it does in the game.
I mean the whole 6 blades will visible on a row on map after i built thể turbine if i don't use h, w, count.

Re: How to use animation

Posted: 08 Aug 2022, 10:02
by Lobby
By using w, h you tell the game the size of individual frames of the animation. The game will then try to get count many such frames from the provided image. The game will not calculate w, h automatically for count>1