Skip to content

Libgdx Runtime

Avetis edited this page Oct 22, 2021 · 6 revisions

Getting started with talos libgdx runtime.

Using Talos runtime with libGDX runtime consists of the following steps:

  1. Setting up your build.gradle
  2. Exporting assets from the editor
  3. Loading your assets in-game
  4. Creating effect and updating it
  5. Rendering it all on screen

Setting up your build.gradle

First off you will need to make sure your build.gradle contains Tloas implementation in the dependencies list.

dependencies { implementation "com.talosvfx:talos-libgdx:1.4.0" }

After adding this and gradle syncing your project, things from runtime should be visible in your project

If you want to check out demo sources of the usage, check out: (code)

Exporting Assets From the Editor

When finished making an effect using Talos editor, just head to File->Export to export the file with .p extension. After that make sure to pack all textures that were used in this effect into a TextureAtlas file like you usually do.

Loading your assets in-game

Load your texture atlas using wither AssetManager or just directly from file:

TextureAtlas textureAtlas = new TextureAtlas(Gdx.files.internal("/path/to/textureAtlas.atlas"));

The next step is to load the effect descriptor that you will later use to spawn effects of that type:

ParticleEffectDescriptor effectDescriptor = new ParticleEffectDescriptor(Gdx.files.internal("/path/to/effect.p"), textureAtlas);

Creating effect and updating it

Effect descriptor is then used to obtain effect instances

ParticleEffectInstance effect = effectDescriptor.createEffectInstance();

When you have the effect it is started by default. And you have to update it on each frame in your act or render or whatever method you have for that that ticks on each frame:

 effect.update(Gdx.graphics.getDeltaTime());

Rendering it all on-screen

To render a Talos effect you need to create your own or use a default particle renderer.

SpriteBatchParticleRenderer defaultRenderer = new SpriteBatchParticleRenderer();
defaultRenderer.setBatch(batch); // use your PolygonSpriteBatch for that, since some effect require polygons to render

Finally, as your effect is loaded working, and animated it's time to simply render it on each frame:

effect.render(defaultRenderer);

That's it.

Clone this wiki locally