Jump to content

Gillmog

Members
  • Posts

    3
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by Gillmog

  1. You need to add box to your spriter project than check collision.

    var object_index = spriter_find_object(self, "box_000");
    
    if object_index != -1
    {
        var top_left_x = spriter_get_box_point_x(self, object_index, "TopLeft");
        var top_left_y = spriter_get_box_point_y(self, object_index, "TopLeft");
        var bottom_right_x = spriter_get_box_point_x(self, object_index, "BottomRight");
        var bottom_right_y = spriter_get_box_point_y(self, object_index, "BottomRight");
      
      	//2D collision detection
    }

    Another way:

    var object_index = spriter_find_object(self, "box_000");
    
    if object_index != -1
    {
         var top_left_x = spriter_GetObjectInfoMeshPointX(modelIndex, instanceIndex, object_index, 0);
         var top_left_y = spriter_GetObjectInfoMeshPointY(modelIndex, instanceIndex, object_index, 0);
         var top_right_x = spriter_GetObjectInfoMeshPointX(modelIndex, instanceIndex, object_index, 1);
         var top_right_y = spriter_GetObjectInfoMeshPointY(modelIndex, instanceIndex, object_index, 1);
         var bottom_right_x = spriter_GetObjectInfoMeshPointX(modelIndex, instanceIndex, object_index, 2);
         var bottom_right_y = spriter_GetObjectInfoMeshPointY(modelIndex, instanceIndex, object_index, 2);
         var bottom_left_x = spriter_GetObjectInfoMeshPointX(modelIndex, instanceIndex, object_index, 3);
         var bottom_left_y = spriter_GetObjectInfoMeshPointY(modelIndex, instanceIndex, object_index, 3);
    
    	 //2D collision detection
    }

    or:

    if (spriter_get_box_collision_rectangle(self, enemy, "box_000") != undefined)
    {
    	//Collision
    }

     

    Безымянный.png

  2. spriter_GetObjectInfoName(...) return name of box, point and bone objects. spriter_GetObjectInfoType(...) return enum such as UNKNOWN = 0, IMAGE = 1, BOX = 2, POINT = 3, BONE = 4. For example:

    var count = spriter_GetObjectInfoCount(modelIndex, instanceIndex);
    
    for (i = 0; i < count; i++)
    {
        var type = spriter_GetObjectInfoType(modelIndex, instanceIndex, i);
        var name = spriter_GetObjectInfoFileName(modelIndex, instanceIndex, i);
        
        if (type != 1)
        {
            name = spriter_GetObjectInfoName (modelIndex, instanceIndex, i);
        }
    }

    I think for the color you need to use ds_map.

    var count = spriter_GetObjectInfoCount(modelIndex, instanceIndex);
    
    for (i = 0; i < count; i++)
    {
        var type = spriter_GetObjectInfoType(modelIndex, instanceIndex, i);
        var name = spriter_GetObjectInfoFileName(modelIndex, instanceIndex, i);
        
        if (type != 1)
        {
            name = spriter_GetObjectInfoName(modelIndex, instanceIndex, i);
        }
        
        blend = image_blend;
        
        if (ds_map_exists(color_map, name))
        {
            blend = ds_map_find_value(color_map, name);
        }
    }

     

  3. 15 hours ago, saga55555 said:

    I testing the tutorial and everything work fine.

    But I noticed one problem.  The animation caused memory leak!

    The memory slowly increase.  I try to put 20+ moss golems in and memory increase faster :shock:

    Is memory increase because of bone moving?

    Memory leak is fixed. Extension moved here https://github.com/Gillmog/spriterGM/blob/master/extension/spriterGM.gmez

×
×
  • Create New...