YoYoGames / GameMaker-Bugs

Public tracking for GameMaker bugs
22 stars 8 forks source link

Allow sprites to be assigned to instances placed in the room editor #3733

Open iampremo opened 1 year ago

iampremo commented 1 year ago

User request message on ticket [Ticket #187260]

 

Feature Type: feat_addition_ide Description: When double-clicking an instance within the room editor, you currently have the ability to change which object is assigned to this instance. However, it would be great to have an option on this window to customise the sprite assigned to the instance (which could override the one already assigned to the object). This means you could see the various instances of the same object placed in a room, with the sprites you've set them, which would then set their sprite_indexes upon game start.

This would be particularly helpful as there may be times where a person needs to be able to use lots of the same object in order to achieve something like a drawing, or depth-sorting system. Something streamlined where a job is performed by lots of instances of the same object.

This can however become problematic when hand-placing objects into the room editor and needing to be able to precisely place them to construct the room. Currently the only way to 'see' a sprite in the room editor is to assign it to a unique object (or place it on as asset layer). As a result, to be able to place lots of sprites down (that are all handled by the aforementioned system), they all need to have their own object, then parented to a controller object of sorts. In some cases I have had to make thousands of extra objects for this. It ends up being a lot of bloat on the project and is very time-consuming to set up.

(This is linked to an earlier feature request I made a few days ago about mass-object creation. In some cases a mass object creation feature would be unnecessary if this feature was present.) Benefit: If I was able to make a single object responsible for handling scenery, then simply change which sprite is assigned to each instance (with this being visible in the room editor), this would save a huge amount of time, and would open up the opportunity for better instance customisation whilst in the room editor.

Totobal5 commented 1 year ago

Please !!

phablix commented 1 year ago

Yes please!!

Alphish commented 1 year ago

As for the use-case mentioned there, i.e. y-depth sorting sprites, I handled it by having specifically named asset layers, and then creating y-depth sorted instances from the sprites. In some cases, it may be a lot more convenient than using the proposed sprite assignment functionality.

That said, there are many other applications, like e.g. placing a shared NPC object with different sprites, to be able to tell at a glance which NPC is which. So I very much support this suggestion!

phablix commented 1 year ago

As for the use-case mentioned there, i.e. y-depth sorting sprites, I handled it by having specifically named asset layers, and then creating y-depth sorted instances from the sprites. In some cases, it may be a lot more convenient than using the proposed sprite assignment functionality.

That said, there are many other applications, like e.g. placing a shared NPC object with different sprites, to be able to tell at a glance which NPC is which. So I very much support this suggestion!

I do that too, but it would save a lot of time to have this functionality. It is also difficult to align the asset layer sprite with the instance that is represented by a question mark.

ThomazDiniz commented 1 month ago

To anyone here interested in a workaround, I made one that I found to be quite nice today:

Create an asset layer and add your sprites as if they were objects. At the start of the room, use a function like this:

var _all_elements = layer_get_all_elements("sprites");
for (var _i = 0; _i < array_length(_all_elements); _i++;){
    if (layer_get_element_type(_all_elements[_i]) == layerelementtype_sprite) {
        var _spr_layer  = _all_elements[_i];
        var _spr        = layer_sprite_get_sprite(_spr_layer);
        var _img        = layer_sprite_get_index(_spr_layer);
        var _x          = layer_sprite_get_x(_spr_layer);
        var _y          = layer_sprite_get_y(_spr_layer);
        var _ang        = layer_sprite_get_angle(_spr_layer);
        var _blend      = layer_sprite_get_blend(_spr_layer);
        var _xs         = layer_sprite_get_xscale(_spr_layer);
        var _ys         = layer_sprite_get_yscale(_spr_layer);
        var _alpha      = layer_sprite_get_alpha(_spr_layer);

        instance_create_layer(_x,_y,layer,obj_map_interactable, 
        {   
            sprite_index: _spr,
            image_index: _img,
            image_xscale: _xs,
            image_yscale: _ys,
            image_angle: _ang,
            image_blend: _blend,
            image_alpha: _alpha
        });

        layer_sprite_destroy(_spr_layer);
    }
}

This code deletes all sprites from a given asset layer, and recreates them as a specific instance. It's not perfect, but it works when you want to do fast level design where for instance your collision object is the same but your sprites changes! Or when you are doing a world map that has different sprites and the object is the same but the sprite changes.

ThomazDiniz commented 1 month ago

Btw, FYI this is the same issue as #2654