Is it possible to change the location of a UI element over time? Like for example, moving something on or offscreen.
a sprite-based Gamemaker UI library · By
Sure, it's easy if you use the `getDimensions()` and `setDimensions()` functions along with an animation curve (or `lerp` or even moving it manually with a preset equation).
For example, you can create a panel that initially sits offscreen and then move it in the step event until it reaches the desired position / size.
// Create event var _panel = new UIPanel("Test", -1600, -800, 0, 0, green_panel, UI_RELATIVE_TO.MIDDLE_CENTER);
and then something along the lines of:
var _panel = ui_get("Test"); var _dim = _panel.getDimensions(); if (_dim.offset_x != 0 || _dim.offset_y != 0 || _dim.width != 400 || _dim.height != 300) { _panel.setDimensions(lerp(_dim.offset_x, 0, 0.1), lerp(_dim.offset_y, 0, 0.1), lerp(_dim.width, 400, 0.04), lerp(_dim.height, 300, 0.04)); }
This is just a snippet but hopefully it illustrates how to do it.
Let me know, thx,