tilemap_get_frame

描述

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.


语法:

tilemap_get_frame(tilemap_element_id)


参数:

参数 描述
tilemap_element_id The unique ID value of the tilemap element to get the frame index of


返回:

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


例如:

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.