GameMaker Changing tile animation speed at runtime?

M

MadTinkerer

Guest
Okay, I've been looking through the documentation and forum threads on tile sets and liking most of what I've seen. The base 2 tile animations is fine. The way tile data is handled is fine. The fact that all of the tiles per tile set are animated at the same speed is fine.

What I want to know is: is there a way to set the tile animation speed in code? Specifically, I'm thinking of synchronizing the tile set animations to the BPM of the background music, so if the music changes I can adjust the animation speed to fit.

I can already do this with sprite animations, no problem, but I don't see a way to do it for tile set animations.
 
A

altan0

Guest
Okay, I've been looking through the documentation and forum threads on tile sets and liking most of what I've seen. The base 2 tile animations is fine. The way tile data is handled is fine. The fact that all of the tiles per tile set are animated at the same speed is fine.

What I want to know is: is there a way to set the tile animation speed in code? Specifically, I'm thinking of synchronizing the tile set animations to the BPM of the background music, so if the music changes I can adjust the animation speed to fit.

I can already do this with sprite animations, no problem, but I don't see a way to do it for tile set animations.
EDIT:
I just check with sprite_set_speed() and it doesn't work on sprites that are assigned as tiles. Also, sprite animation and tile animation are two different subjects. AFAIK, there is no way to adjust the tile animation speed during run time.

One workaround is to duplicate the tilesets and set each one a different animation speed. Then use a condition statement to change the tileset according to a variable e.g. speed:
Code:
if (speed >= 5) {
     tilemap_tileset(layer_tilemap_get_id("Tiles_1"),tileset_fps15);
} else {
     tilemap_tileset(layer_tilemap_get_id("Tiles_1"),tileset_fps3);
}
Not the best solution but it functions close to your requirements.

I have not worked on tile animations just yet but one possible solution is to change the sprite animation from the sprite resource itself.

Have you tried sprite_set_speed() with the index value referring to the sprite resource in the Hierarchy window?
 
Last edited by a moderator:
M

MadTinkerer

Guest
That almost works, if I could create a tilemap, set it's animation speed, set it to the layer, and then destroy the old one. The problem is the second step.

Also, just FYI, I'm using gamespeed_microseconds for the extra precision.

Actually, wait: I was experimenting with adjusting game_speed to the BPS of the music, so maybe, if I dynamiically adjust the framerate of everything anyway, I don't need to separately adjust the tileset animation speed? Would that still cause problems with switching from 4/4 to 3/4, or would it just all synchronize regardless?

(Those last two questions are rhetorical, I clearly need to do more research and post some actual code. Also, I will try sprite_set_speed() and see if that works too.)

Thanks, Altan. :D
 
Top