tilemap_get_frame

Description

Since tiles can be animated, it can sometimes be useful to know which frame is currently being drawn and react accordingly, so with this function you can retrieve the current frame index for a given tilemap. You give the tilemap element ID (which you get when you create a tilemap element using layer_tilemap_create() or when you use the function layer_tilemap_get_id()), and the function will return the frame index.


Syntax:

tilemap_get_frame(tilemap_element_id)


Arguments:

Argument Description
tilemap_element_id The unique ID value of the tilemap element to get the frame index of


Returns:

Real (between 0 (inclusive) and the maximum number of frames of animation (exclusive))


Example:

var lay_id = layer_get_id("Tiles_Traps");
var map_id = layer_tilemap_get_id(lay_id);
if tilemap_get_frame(map_id) >= 2 && tilemap_get_frame(map_id) < 4
   {
   global.activate = true;
   }
else
   {
   global.activate = false;
   }

The above code checks the current animation frame for the given tilemap on the given layer, and sets a global variable based on the return value.