YoYoGames / GameMaker-Bugs

Public tracking for GameMaker bugs
26 stars 8 forks source link

Manual Sequence Drawing #2931

Open ghost opened 1 year ago

ghost commented 1 year ago

Is your feature request related to a problem?

Other layer element types can be drawn manually with code relatively easily:

draw_tilemap(...);
layer_background_get_sprite(...);
layer_sprite_get_sprite(...);

Sequences do not have this benefit, and are only drawn when a layer is drawn.

Describe the solution you'd like

Add a function where you can draw a sequence instance:

layer_sequence_draw(sequence_instance, [x], [y], [draw_event_number]);

By default, only giving it the instance struct, it would draw the sequence with the default Draw event at its given position. Can be moved around with optional arguments, and an event number can also be specified with another argument, if you have objects nested in the sequence that have other Draw events.

Describe alternatives you've considered

I use sequences for room transitions. I draw sequences to a surface with layer scripts, and then draw the surface with Draw GUI for them to work. My game runs at 1920x1080, so it seems wasteful to use a surface that size just to draw them.

Additional context

No response

AtlaStar commented 1 year ago

duplicate of YoYoGames/GameMaker-Bugs#3515

but yeah, this would be nice and has been being asked for for a while. Should also take a look at YoYoGames/GameMaker-Bugs#3452 (including it here since some older FRs added by YYG seem to sometimes get forgotten) which imo is complimentary to this request.

AtlaStar commented 1 year ago

Also looks like YoYoGames/GameMaker-Bugs#3775 is a request for drawing sequences manually.

Ghoulcel commented 8 months ago

In case anyone still needs info on this I managed to get the concept of drawing sequence sprites manually working. Wanted to use sequences to do rig based animation for characters, but also wanted to manipulate the character based on reaction, like white flashes when taking damage. In the create event I just used layer_sequence_create() and set the visibility of all the tracks to false to hide the sequence then entered the sequence into this function inside the draw event to redraw it manually:

function draw_sequence(_sequence, _x, _y)
{
    var _seq = layer_sequence_get_instance(_sequence);
    //Loop through all tracks in sequence
    for(var _i = 0; _i < array_length(_seq.activeTracks); _i++)
    {
        var _track = _seq.activeTracks[_i]; //Current Track
        var _sprite = _track.track.keyframes[0].channels[0].spriteIndex; //Sprite Of Track
        var _color = _track.colormultiply //ARGB Color Value
                draw_sprite_ext(_sprite, _track.imageindex, _x+_track.posx, _y+_track.posy, _track.scalex, _track.scaley, _track.rotation, make_color_rgb(_color[1]*255,_color[2]*255,_color[3]*255), _color[0]);
    }
}

Not sure if there is a better way to do this but this was the closest post I could find talking about it, so I figured I should share what worked for me. Btw this probably only works if only sprites are in the sequence, but checking the track type should help. if(_track.track.type == seqtracktype_graphic)