Tilesource animation name

#1

Hey everyone,

I’m using tilemap to design levels of a “puzzle game”

I need to replace tiles with sprites to give it some animation:

I’ve defined animation names in the tilesource.

The missing link is how to determine animation name from the tile id.

Board replacement method looks like this:

The hardcoded mapping needs to be updated with tilesource changes.

Will be beautiful to have some api to get the tilesource used by the tilemap and then get the animation name from the tileindex. (like in the comment)

Thanks in advance

0 Likes

#2

Yeah, at the moment you need to do a manual lookup between tile index and animation.

0 Likes

#3

I think this is a good case for doing the animation in the shader instead.

2 Likes

#4

Now the animation is managed by “animating” tint in each sprite shader using a delay.
Doing the same thing in the tilemap shader is possible, but it is hadred to code for me :sweat_smile:
I’ve poor skill with shaders :woozy_face:
I’ll try!!!

0 Likes

#5

I’m tring to implement the “blocks lighting” effect in the tilemap shader.

I see tilemap material have only sampler and tint uniform parameters.

It will be useful to have uniform parameter with tile index (x,y) and layer index in fragment and vertex shaders. A vec4 can hold all informations!

Without layer index I’ll have to split each tilemap into 2 different tilemaps, but I’ve already designed 30 levels …

Tile index is useful because now I can calculate it in the vertex shader from position, but the only way to forward it to fragment, is with varying, so it has to be clamped. (flat out variables seems to work only with GLES30)

@Mathias_Westerdahl is there any way to add these uniform in the material or need an engine change?

Thank in advance

0 Likes

#6

It will be useful to have uniform parameter with tile index (x,y) and layer index in fragment and vertex shaders. A vec4 can hold all informations!

This would however break the batching which would give you one draw call per tile.
This is not an approach we would recommend.

For the tile index, I suggest you do some arithmetic on the position to find out what tile index it is. I.e. divide by tile size.

Without layer index I’ll have to split each tilemap into 2 different tilemaps, but I’ve already designed 30 levels …

The file format is text based, so you can read a file, and output another.
You could create a script that creates these extra tilemaps if you wish.

2 Likes

Tilemap issues
#7

I managed to implement the effect in the shaders as you suggested.

It works better, it’s more flexible and faster :upside_down_face:

Thanks for the suggestion and support :+1::+1::+1:

4 Likes