Skip to content

4. Static Functions

Triangly edited this page Dec 18, 2024 · 2 revisions

Animation

ani_add_sprite

Registers a sprite asset from the room to play its animation in accordance with the game loop.

Arguments:

  • spriteid - Asset.GMSprite - The identifier of the sprite to be registered.
  • duration - Real - The duration for which each frame of the animation is displayed, in game steps.

ani_run_by_timer

Plays the animation for the object without using the Animator module, directly updating the object's image_index based on the current timer value and the frame duration.

Arguments:

  • timer - Real - The timer value.
  • duration - Real - The duration of one frame of the animation, in game steps.

ani_get_duration

Returns the duration of the current animation frame of the object, in game steps.

Scope:

  • c_object

Returns:

  • Real

ani_get_ended

Checks if the object's animation has finished playing.

Scope:

  • c_object

Returns:

  • Bool

ani_get_ended

Returns the index of the current animation frame of the object. The index may differ from the built-in image_index if a custom frame sequence has been set.

Scope:

  • c_object

Returns:

  • Real

ani_get_frame_changed

Checks if the frame of the object's current animation has changed.

Scope:

  • c_object

Returns:

  • Bool

ani_get_stopped

Checks if the playback of the object's current animation has been manually stopped.

Scope:

  • c_object

Returns:

  • Bool

ani_get_timer

Returns the current frame timer of the object's animation, indicating how many game steps remain until the frame changes.

Scope:

  • c_object

Returns:

  • Real

ani_resume

Resumes playback of the object's current animation from the current frame, resetting the frame timer to its default value.

Scope:

  • c_object

ani_start

Registers a new animation for the object and immediately starts playing it.

Arguments:

  • spriteid - Asset.GMSprite - The sprite asset.
  • duration - Real or Array<Real> - The duration of the frames in the object's current animation (optional, defaults to 0). Refer to ani_update_duration() function for more information.
  • start_frame - Real - The index of the starting frame of the animation. If a custom sequence is provided, this will be the index of the frame in that sequence (optional, defaults to 0).
  • loop_frame - Real - The index of the frame to which the animation will loop back after playing the last frame in the sequence. If a custom sequence is provided, this will be the index of the frame in that sequence (optional, defaults to 0).
  • order - Array<Real> - The custom frame playback sequence (optional, defaults to []).

Scope:

  • c_object

ani_stop

Stops the playback of the object's current animation.

Scope:

  • c_object

ani_update

Updates several parameters of the object's current animation.

Arguments:

  • frame - Real or Undefined - Refer to ani_update_frame() function. Pass undefined if no changes are required.
  • reset_timer - Bool - Refer to ani_update_frame() function.
  • order - Array<Real> or Undefined - Refer to ani_update_order() function. Pass undefined if no changes are required.
  • duration - Real or Array<Real> or Undefined - Refer to ani_update_duration() function. Pass undefined if no changes are required.
  • loop_frame - Real or Undefined - Refer to ani_update_loopframe() function. Pass undefined if no changes are required.

Scope:

  • c_object

ani_update_duration

Updates the duration of the frames in the object's current animation. This can be provided as a single value for all frames or as an array of values representing the duration of each frame. If provided as an array, its length should match the number of frames in the asset or the number of frames in the custom playback sequence.

Arguments:

  • duration - Real or Array<Real> - The duration of one frame of the animation in game steps.

Scope:

  • c_object

ani_update_frame

Updates the current frame index of the object's animation.

Arguments:

  • frame - Real - The new frame index of the animation. If the animation is a custom sequence, this will be the index of the frame in that sequence.
  • reset_timer - Bool - If true, resets the current frame timer to its default value (optional, defaults to true).

Scope:

  • c_object

ani_update_loopframe

Updates the index of the frame to which the object's current animation will loop back after playing the last frame in the sequence.

Arguments:

  • loop_frame - Real - The index of the frame to which the animation will return after playing the last frame. If a custom sequence is used, this will be the index of the frame in that sequence.

Scope:

  • c_object

ani_update_order

Updates the animation frame order for the current object.

Arguments:

  • order - Array<Real> - An array specifying the order of frames.

Scope:

  • c_object

Audio

audio_bgm_is_playing

Checks if BGM is playing on the specified channel.

Arguments:

  • channel_index - Real - The index of the channel (optional, defaults to 0).

audio_mute_bgm

Mutes the BGM on the specified channel.

Arguments:

  • time - Real - The duration over which the volume will decrease to 0, in seconds.
  • channel_index - Real - The index of the channel (optional, defaults to 0).

audio_play_bgm

Starts playing BGM on the specified channel. If the same BGM is already playing on the channel, no action is taken.

Arguments:

  • sound_id - Asset.GMSound - The sound asset to be played as BGM.
  • channel_index - Real - The index of the channel (optional).

Returns:

  • Id.Sound

audio_play_sfx

Plays a sound effect, stopping any currently playing instance of the same sound asset.

Arguments:

  • soundid - Asset.GMSound - The sound asset to be played as SFX.
  • loop - Array<Real> - An array of two values specifying the loop points of the sound, in seconds; if empty, the sound will not loop (optional, defaults to []).

Returns:

  • Id.Sound

audio_reset_bgm

Resets the background music (BGM) based on the state of the specified player or plays the default BGM if no player is provided.

Arguments:

  • default_bgm - Asset.GMSound - The default BGM sound asset to be played if no special conditions are met.
  • player - Id.Instance - The player instance whose state determines which BGM to play (optional, defaults to noone).

audio_stop_bgm

Stops the BGM on the specified channel, fading out the volume over a given duration.

Arguments:

  • time - Real - The duration over which the volume will decrease to 0, in seconds.
  • channel_index - Real - The index of the channel (optional, defaults to 0).

audio_unmute_bgm

Unmutes the BGM on the specified channel, gradually increasing the volume back to the standard level.

Arguments:

  • time - Real - The duration over which the volume will be increased to the standard level, in seconds.
  • channel_index - Real - The index of the channel (optional, defaults to 0).

audio_set_bgm_loop

Sets the loop points for the specified BGM sound asset.

Arguments:

  • soundid - Asset.GMSound - The sound asset for which the loop points are being set.
  • loopstart - Real - The start point of the loop, in seconds.
  • loopend - Real - The end point of the loop, in seconds.

Background

bg_add_layer

Adds a parallax layer to the background of the current room.

Arguments:

  • sprite_id - Asset.GMSprite - The sprite asset to be used for the layer.
  • draw_node - Real - The y position on the sprite of the top edge of the area to draw.
  • draw_height - Real - The height of the area to draw.
  • pos_offset - Real - The vertical offset of the layer.
  • ani_duration - Real - The duration of each frame of the layer’s animation, in game steps.
  • scroll_vel_x - Real - The horizontal scroll speed of the layer’s content.
  • scroll_vel_y - Real - The vertical scroll speed of the layer’s content.
  • factor_x - Real - The horizontal parallax factor. Lower values make the layer appear further from the camera.
  • factor_y - Real - The vertical parallax factor. Lower values make the layer appear further from the camera.

bg_clear

Clears all current background layers along with their distortion effects and optionally fills the background with a new solid colour.

Arguments:

  • colour - Real - The colour to fill the background with. Pass undefined to retain the current colour (optional, defaults to undefined).

bg_set_colour

Fills the background with a new solid colour.

Arguments:

  • _colour - Real - The new background colour.

bg_set_perspective_x

Applies a horizontal perspective effect to the most recently added background layer.

Arguments:

  • target_x - Real - The target horizontal parallax factor for the bottom edge of the layer.
  • line_height - Real - The height of one line of the perspective.

bg_set_perspective_y

Applies a vertical perspective effect to the most recently added background layer. Only one layer with a vertical perspective is supported.

Arguments:

  • target_y - Real - The y position within the room from which the layer will be scaled.

Camera

camera_new

Creates a new camera and assigns it to a new surface, returning a struct containing its data. It will delete any existing camera assigned to the same index.

Arguments:

  • index - Real - The index to assign the new camera to.
  • width - Real - The horizontal resolution of the camera.
  • height - Real - The vertical resolution of the camera.
  • canvas_width - Real - The horizontal size of the canvas (surface).
  • canvas_height - Real - The vertical size of the canvas (surface).
  • pos_x - Real - The initial x position of the camera in the room (optional, defaults to 0).
  • pos_y - Real - The initial y position of the camera in the room (optional, defaults to 0).
  • canvas_x - Real - The horizontal offset of the surface on the screen (optional, defaults to 0).
  • canvas_y - Real - The vertical offset of the surface on the screen (optional, defaults to 0).

Returns:

  • Struct

camera_update

Updates the size of the camera associated with the specified viewport index. The current size is maintained if no new size is provided.

Arguments:

  • index - Real - The index of the viewport.
  • width - Real or Undefined - The new width of the camera. Pass undefined to retain the current width.
  • height - Real or Undefined - The new height of the camera. Pass undefined to retain the current height.
  • pos_x - Real or Undefined - The new x position of the camera in the room. Pass undefined to retain the current position.
  • pos_y - Real or Undefined - The new y position of the camera in the room. Pass undefined to retain the current position.

camera_update_surface

Updates the surface associated with the specified viewport index. The current resolution is maintained if no new resolution is provided.

Arguments:

  • index - Real - The index of the viewport.
  • canvas_width - Real or Undefined - The new horizontal resolution of the surface. Pass undefined to retain the current width.
  • canvas_height - Real or Undefined - The new vertical resolution of the surface. Pass undefined to retain the current height.
  • x - Real or Undefined - The horizontal offset of the surface. Pass undefined to retain the current offset (optional, defaults to 0).
  • y - Real or Undefined - The vertical offset of the surface. Pass undefined to retain the current offset (optional, defaults to 0).

camera_delete

Deletes the camera and the surface associated with the specified viewport index.

Arguments:

  • index - Real - The index of the viewport.

camera_get

Returns the camera associated with the specified viewport index.

Arguments:

  • index - Real - The index of the viewport.

Returns:

  • Id.Camera

camera_get_data

Returns the data of the camera associated with the specified viewport index.

Arguments:

  • index - Real - The index of the viewport.

Returns:

  • Struct or Id.Instance

camera_get_width

Returns the horizontal resolution of the camera associated with the specified viewport index.

Arguments:

  • index - Real - The index of the viewport.

Returns:

  • Real

camera_get_height

Returns the vertical resolution of the camera associated with the specified viewport index.

Arguments:

  • index - Real - The index of the viewport.

Returns:

  • Real

camera_get_x

Returns the adjusted x position of the camera associated with the specified viewport index.

Arguments:

  • index - Real - The index of the viewport.

Returns:

  • Real

camera_get_y

Returns the y position of the camera associated with the specified viewport index.

Arguments:

  • index - Real - The index of the viewport.

Returns:

  • Real

Collision

collision_generate

If global.tools_binary_collision flag is set, this function will not store the generated collision in the game memory but instead save it into the Save Location folder (see Game Options for your specific platform).

Generates collision data for the tilemap associated with the specified sprite.

Arguments:

  • sprite_id - Asset.GMSprite - The sprite used in the tilemap.
  • angle_data - Array<Real> - An array of values representing the angles for each tile.
  • off_x - Real - The horizontal offset of the sprite on the tilemap.
  • off_y - Real - The vertical offset of the sprite on the tilemap.
  • sep_x - Real - The horizontal spacing between tiles on the tilemap.
  • sep_y - Real - The vertical spacing between tiles on the tilemap.

Scope:

  • scr_fw_collision_setup

collision_load

Loads the generated collision data for the tilemap associated with the specified sprite.

Arguments:

  • spriteid - Asset.GMSprite - The sprite used in the tilemap for which the collision data was generated.
  • layer_a - String - The name of the primary layer in the room.
  • layer_b - String - The name of the secondary layer in the room.

collision_load_binary

Loads collision data from binary files located in in /datafiles/collision. This function does not associate the data with any specific tilemap, so ensure you are loading data for the tilemap you are using.

Arguments:

  • width_data - String - The filename (without extension) containing width data.
  • height_data - String - The filename (without extension) containing height data.
  • angle_data - String - The filename (without extension) containing angle data.
  • layer_a - String - The name of the primary layer in the room.
  • layer_b - String - The name of the secondary layer in the room.

Tiles

tile_find_v

Finds a tile along a vertical axis at the given position within a specified tile layer and returns an array containing two values: the distance to the tile's edge and its angle.

Arguments:

  • x - Real - The x-coordinate of the position.
  • y - Real - The y-coordinate of the position.
  • dir - Enum.DIRECTION - The direction in which to perform the search.
  • layer - Enum.TILELAYER - The index of the tile layer to search within.
  • behaviour - Enum.TILEBEHAVIOUR - The behaviour type of the tile (optional, defaults to DEFAULT).

Returns:

  • Array<Real> - An array containing the distance to the tile's edge at position 0 and and its angle at position 1.

tile_find_h

Finds a tile along a horizontal axis at the given position within a specified tile layer and returns an array containing two values: the distance to the tile's edge and its angle.

Arguments:

  • x - Real - The x-coordinate of the position.
  • y - Real - The y-coordinate of the position.
  • dir - Enum.DIRECTION - The direction in which to perform the search.
  • layer - Enum.TILELAYER - The index of the tile layer to search within.
  • behaviour - Enum.TILEBEHAVIOUR - The behaviour type of the tile (optional, defaults to DEFAULT).

Returns:

  • Array<Real> - An array containing the distance to the tile's edge at position 0 and and its angle at position 1.

tile_find_2v

Identifies the nearest tile along a vertical axis between two given points and returns an array containing two values: the distance to the found tile's edge and its angle.

Arguments:

  • x1 - Real - The x-coordinate of the first point.
  • y1 - Real - The y-coordinate of the first point.
  • x2 - Real - The x-coordinate of the second point.
  • y2 - Real - The y-coordinate of the second point.
  • dir - Enum.DIRECTION - The direction in which to perform the search.
  • layer - Enum.TILELAYER - The index of the tile layer to search within.
  • behaviour - Enum.TILEBEHAVIOUR - The behaviour type of the tile (optional, defaults to DEFAULT).

Returns:

  • Array<Real> - An array containing the distance to the closest tile's edge at position 0 and and its angle at position 1.

tile_find_2h

Identifies the nearest tile along a horizontal axis between two given points and returns an array containing two values: the distance to the found tile's edge and its angle.

Arguments:

  • x1 - Real - The x-coordinate of the first point.
  • y1 - Real - The y-coordinate of the first point.
  • x2 - Real - The x-coordinate of the second point.
  • y2 - Real - The y-coordinate of the second point.
  • dir - Enum.DIRECTION - The direction in which to perform the search.
  • layer - Enum.TILELAYER - The index of the tile layer to search within.
  • behaviour - Enum.TILEBEHAVIOUR - The behaviour type of the tile (optional, defaults to DEFAULT).

Returns:

  • Array<Real> - An array containing the distance to the closest tile's edge at position 0 and and its angle at position 1.

tile_get_angle

Retrieves the angle of a tile based on its index. Returns ANGLE_EMPTY if the tile of the given index is non-existent.

Arguments:

  • tiledata - Real - The tile data.

Returns:

  • Real or Constant

tile_get_height

Retrieves the height of a specific tile in the room at a given x-coordinate within itself. Returns 0 if the tile index is invalid.

Arguments:

  • tiledata - Real - The tile data.
  • x - Real - The x-coordinate within the tile.

Returns:

  • Real

tile_get_width

Retrieves the width of a specific tile in the room at a given y-coordinate within itself. Returns 0 if the tile index is invalid.

Arguments:

  • tiledata - Real - The tile data.
  • y - Real - The y-coordinate within the tile.

Returns:

  • Real

tile_get_validity_v

Evaluates the validity of a tile along a vertical axis based on the specified direction and tile behaviour.

Arguments:

  • tiledata - Real - The tile data.
  • dir - Enum.DIRECTION - The direction to check the tile's validity.
  • behaviour - Enum.TILEBEHAVIOUR - The behaviour of the tile to consider when evaluating validity.

Returns:

  • Bool

tile_get_validity_h

Evaluates the validity of a tile along a horizontal axis based on the specified direction and tile behaviour.

Arguments:

  • tiledata - Real - The tile data.
  • dir - Enum.DIRECTION - The direction to check the tile's validity.
  • behaviour - Enum.TILEBEHAVIOUR - The behaviour of the tile to consider when evaluating validity.

Returns:

  • Bool

Distortion

dist_set_fg

Applies distortion to multiple foreground layers using two sets of distortion data. Distortion is not applied to object instance layers.

Arguments:

  • data1 - Array<Real> - The first set of distortion data.
  • data2 - Array<Real> - The second set of distortion data.
  • spd - Real - The speed of distortion.
  • range_start - Real - The upper boundary of the distortion area, in room space.
  • range_end - Real - The lower boundary of the distortion area, in room space.
  • layers - Array<String> - An array of layer names to which the distortion will be applied.

dist_set_bg

Applies distortion to the background layer using two sets of distortion data.

Arguments:

  • data1 - Array<Real> - The first set of distortion data.
  • data2 - Array<Real> - The second set of distortion data.
  • spd - Real - The speed of distortion.
  • range_start - Real - The upper boundary of the distortion area, in background space.
  • range_end - Real - The lower boundary of the distortion area, in background space.

dist_clear_fg

Clears all active distortion effects from the foreground.


dist_clear_bg

Clears all active distortion effects from the background.


dist_get_data

Returns data representing the distortion pattern (shape).

Arguments:

  • effect_data - Enum.EFFECTDATA - An enum representing the type of distortion data.

Returns:

  • Array<Integer>

Draw

draw_line_floored

Draws a line with coordinates rounded down to the nearest integer.

Arguments:

  • x1 - Real - The x-coordinate of the line's starting point.
  • y1 - Real - The y-coordinate of the line's starting point.
  • x2 - Real - The x-coordinate of the line's ending point.
  • y2 - Real - The y-coordinate of the line's ending point.
  • col1 - Constant.Color - The colour of the line at the starting point (optional, defaults to c_white).
  • col2 - Constant.Color - The colour of the line at the ending point (optional, defaults to col1).

draw_point_floored

Draws a point with coordinates rounded down to the nearest integer.

Arguments:

  • x1 - Real - The x-coordinate of the point.
  • y1 - Real - The y-coordinate of the point.
  • col - Constant.Color - The colour of the point (optional, defaults to c_white).

draw_rect_floored

Draws a rectangle with coordinates rounded down to the nearest integer.

Arguments:

  • x1 - Real - The x-coordinate of the top-left corner.
  • y1 - Real - The y-coordinate of the top-left corner.
  • x2 - Real - The x-coordinate of the bottom-right corner.
  • y2 - Real - The y-coordinate of the bottom-right corner.
  • is_outlined - Bool - Specifies whether the rectangle should be outlined (true) or filled (false).
  • col - Constant.Color - The colour of the rectangle (optional, defaults to c_white).

draw_toggle_fade

Toggles the fade effect for all subsequent drawing calls.

Arguments:

  • enabled - Bool - A boolean flag to enable or disable the fade effect.

draw_toggle_palette

Toggles colour palette replacement for all subsequent drawing calls.

Arguments:

  • enabled - Bool - A boolean flag to enable or disable the colour palette replacement.

Fade

fade_perform

Configures and triggers a screen fade effect. If unsure, use the pre-configured functions.

Arguments:

  • routine - Enum.FADEROUTINE - The type of fade action to perform (e.g., fade-in or fade-out).
  • type - Enum.FADETYPE - The colour blending type used during the fade effect.
  • speed - Real - The speed at which the fade effect occurs.
  • freq - Real - The number of game steps between each update of the effect, affecting the smoothness of the transition (optional, defaults to 1).
  • game_control - Bool - Whether to pause game updates during the fade effect or not (optional, defaults to true).

fade_perform_black

Performs a black fade effect.

Arguments:

  • routine - Enum.FADEROUTINE - The type of fade action to perform (e.g., fade-in or fade-out).
  • step_duration - Real - The duration of the effect update in game steps, affecting both speed and smoothness.
  • game_control - Bool - Whether to pause game updates during the fade effect (optional, defaults to true).

fade_perform_dull

Performs a dull fade effect.

Arguments:

  • routine - Enum.FADEROUTINE - The type of fade action to perform (e.g., fade-in or fade-out).
  • step_duration - Real - The duration of the effect update in game steps, affecting both speed and smoothness.
  • game_control - Bool - Whether to pause game updates during the fade effect (optional, defaults to true).

fade_perform_flash

Performs a flash fade effect.

Arguments:

  • routine - Enum.FADEROUTINE - The type of fade action to perform (e.g., fade-in or fade-out).
  • step_duration - Real - The duration of the effect update in game steps, affecting both speed and smoothness.
  • game_control - Bool - Whether to pause game updates during the fade effect (optional, defaults to true).

fade_perform_white

Performs a white fade effect.

Arguments:

  • routine - Enum.FADEROUTINE - The type of fade action to perform (e.g., fade-in or fade-out).
  • step_duration - Real - The duration of the effect update in game steps, affecting both speed and smoothness.
  • game_control - Bool - Whether to pause game updates during the fade effect (optional, defaults to true).

Input

input_create

Creates a new input structure.

Returns:

  • Struct

input_get

Retrieves the input data for the specified slot, which includes the held-down status of inputs.

Arguments:

  • slot - Real - The input slot number.

Returns:

  • Struct

input_get_pressed

Retrieves the input data for the specified slot, which includes the pressed status of inputs.

Arguments:

  • slot - Real - The input slot number.

Returns:

  • Struct

input_reset

Resets the input data contained within the given structure.

Arguments:

  • struct - Struct - The structure containing the input data to be reset.

input_set_rumble

Sets a rumble effect on the specified gamepad slot.

Arguments:

  • input_id - Real - The ID of the gamepad slot to apply the rumble effect to.
  • time - Real - The duration of the rumble effect in seconds.
  • left_motor - Real - The intensity of the rumble effect for the left motor, ranging from 0 to 1.
  • right_motor - Real - The intensity of the rumble effect for the right motor, ranging from 0 to 1.

Math

math_get_angle_degree

Converts a raw angle to its equivalent angle in degrees.

Arguments:

  • raw - Real - The raw angle to convert.

Returns:

  • Real

math_get_angle_raw

Converts an angle in degrees to its equivalent raw angle.

Arguments:

  • decimal - Real - The angle in degrees to convert.

Returns:

  • Real

math_get_quadrant

Converts an angle in degrees to its corresponding quadrant from 0 to 3.

Arguments:

  • angle - Real - The angle in degrees.

Returns:

  • Real

math_get_vector_rounded

Calculates a degree angle of a vector rounded to the nearest value in the raw angle system.

Arguments:

  • x_dist - Real - The x-component of the vector.
  • y_dist - Real - The y-component of the vector.

Returns:

  • Real

math_get_vector

Calculates a degree angle of a vector.

Arguments:

  • x_dist - Real - The x-component of the vector.
  • y_dist - Real - The y-component of the vector.

Returns:

  • Real

math_get_angle_rounded

Rounds an angle in degrees to the nearest value in the raw angle system.

Arguments:

  • angle - Real - The angle in degrees to be rounded.

Returns:

  • Real

Object

obj_set_culling

Sets the culling behaviour for the specified object.

Arguments:

  • type - Enum.CULLING - The new culling behaviour type to be set.

obj_set_hitbox

Configures the object's hitbox by setting its size and offset from the object's centre.

Arguments:

  • radius_x - Real - The horizontal radius of the hitbox.
  • radius_y - Real - The vertical radius of the hitbox.
  • offset_x - Real - The horizontal offset for the hitbox from the object's centre (optional, defaults to 0).
  • offset_y - Real - The vertical offset for the hitbox from the object's centre (optional, defaults to 0).

obj_set_hitbox_ext

Configures the object's extended hitbox by setting its size and offset from the object's centre.

Arguments:

  • radius_x - Real - The horizontal radius of the extended hitbox.
  • radius_y - Real - The vertical radius of the extended hitbox.
  • offset_x - Real - The horizontal offset for the extended hitbox from the object's centre (optional, defaults to 0).
  • offset_y - Real - The vertical offset for the extended hitbox from the object's centre (optional, defaults to 0).

obj_set_priority

Adjusts the object's drawing priority based on the specified priority value from 0 to 8, inclusive.

Arguments:

  • priority - Real - The desired priority level.

obj_set_solid

Configures the object's solid collision area by setting its size and offset relative to the object's centre.

Arguments:

  • radius_x - Real - The horizontal radius of the solid collision area.
  • radius_y - Real - The vertical radius of the solid collision area.
  • offset_x - Real - The horizontal offset of the collision area from the object's centre (optional, defaults to 0).
  • offset_y - Real - The vertical offset of the collision area from the object's centre (optional, defaults to 0).

obj_set_solid_sloped

Configures the collision properties for a sloped object using a heightmap.

Arguments:

  • heightmap - Array<Real> - An array of numbers representing the height at various points.
  • offset_x - Real - The horizontal offset of the collision area from the object's centre (optional, defaults to 0).
  • offset_y - Real - The vertical offset of the collision area from the object's centre (optional, defaults to 0).

obj_reset_priority

Resets the specified object's depth (drawing priority) to its initial value.


obj_is_visible

Checks if the specified object is visible within any of the current view boundaries. Note that this function refers to the any GameMaker camera, not specifically the one created with the camera_new() function.

Arguments:

  • id - Id.Instance - The object instance (optional, defaults to the current instance).

Returns:

  • Bool

obj_act_enemy

Defines the behaviour and logic for an enemy object. Returns true if the enemy was not destroyed, false otherwise.

Arguments:

  • type - Enum.ENEMYTYPE - The type of enemy (optional, defaults to ENEMYTYPE.BADNIK).

Returns:

  • Bool

obj_act_solid

Handles collision detection and response between the player and a solid object.

Arguments:

  • player - Id.Instance - The player object instance.
  • type - Enum.SOLIDOBJECT - The type of solid object.
  • attach_type - Enum.SOLIDATTACH - Whether the player is allowed to land on this object or should they be reset (optional, defaults to DEFAULT).

obj_check_hitbox

Determines whether the calling object collides with the specified target object's hitbox.

Arguments:

  • target - Id.Instance - The object instance to check.
  • use_target_ext - Bool - If true, checks the target's extended hitbox; if false, checks the standard hitbox (optional, defaults to false).

Returns:

  • Bool

obj_check_solid

Checks for solid collision between the calling object and a player object.

Arguments:

  • player - Id.Instance - The player object instance.
  • type - Enum.SOLIDCOLLISION - The type of collision.

Returns:

  • Bool

obj_clear_player_push

Clears the flag that forces a push animation on the specified player object, reverting to the default move animation.

Arguments:

  • player - Id.Instance - The player object instance.

obj_oscillate_x

Oscillates an object's x position based on the specified parameters.

Arguments:

  • start_x - Real - The initial x position for the oscillation.
  • angle - Real - The angle or timer value used for the oscillation.
  • dist - Real - The amplitude of the oscillation, determining how far the object moves from its starting position.
  • spd - Real - The speed at which the oscillation occurs (optional, defaults to 1).
  • offset - Real - A value that shifts the angle of the oscillation (optional, defaults to 0).

Returns:

  • Real

obj_oscillate_y

Oscillates an object's y position based on the specified parameters.

Arguments:

  • start_y - Real - The initial y position for the oscillation.
  • angle - Real - The angle or timer value used for the oscillation.
  • dist - Real - The amplitude of the oscillation, determining how far the object moves from its starting position.
  • spd - Real - The speed at which the oscillation occurs (optional, defaults to 1).
  • offset - Real - A value that shifts the angle of the oscillation (optional, defaults to 0).

Returns:

  • Real

Palette

pal_load

Loads palette information from two sprite textures.

Arguments:

  • primary - Asset.GMSprite - The sprite data for the primary palette.
  • secondary - Asset.GMSprite - The sprite data for the secondary palette.

pal_set_index

Sets the palette index for one or more colour IDs, and optionally stops their colour rotation.

Arguments:

  • col_ids - Array<Real> - An array of colour ID(s) for which to set the palette index.
  • index - Real - The palette index.
  • stop_rotation - Bool - If true, stops the rotation (optional, defaults to false).

pal_get_index

Retrieves the palette index corresponding to a given colour ID.

Arguments:

  • col_id - Real - The colour ID.

Returns:

  • Real

pal_run_rotation

Sets the rotation parameters for one or more colour IDs, enabling them to cycle through the palette over a specified duration.

Arguments:

  • col_ids - Array<Real> - An array of colour IDs for which the rotation parameters are to be set.
  • loop_index - Real - The index within the palette to which the rotation will loop back after it ends.
  • end_index - Real - The ending index within the palette loop where the rotation ends.
  • duration - Real - The duration of each frame in the colour rotation sequence, in game steps.

Player

player_spawn

Spawns a player object of the given type (character) at the specified location. Returns the instance ID of the created player, or noone if the maximum player count is exceeded.

Arguments:

  • x - Real - The x-coordinate of the spawn location.
  • y - Real - The y-coordinate of the spawn location.
  • player_type - Constant - The character to spawn.
  • layer - String - The name of the layer where the player object will be placed.

Returns:

  • Id.Instance

player_get

Retrieves the instance ID of a player object corresponding to the specified player index. Returns noone if no matching player object is found.

Arguments:

  • player_index - Real - The index of the player.

Returns:

  • Id.Instance

Other

discord_set_data

Sets the data displayed in Discord Rich Presence. Requires a configured Application ID for your game, see scr_fw_game_setup() script.

Arguments:

  • upper_text - String or Undefined - The main (upper) line of text to display. Pass undefined if no changes are required.
  • lower_text - String or Undefined - The secondary (lower) line of text to display. Pass undefined if no changes are required.
  • large_image_key - String or Undefined - The key for the main (large) image. Pass undefined if no changes are required.
  • small_image_key - String or Undefined - The key for the secondary (small) image. Pass undefined if no changes are required.

font_register

Registers a sprite as a font. This acts as a wrapper for the font_add_sprite_ext() function.

Arguments:

  • sprite_id - Asset.GMSprite - The sprite asset containing the font characters.
  • mapstring - String - A string defining the arrangement of characters within the sprite.
  • cut_empty_space - Real - Whether to trim empty space around characters (requires "Automatically Crop" enabled in Texture Group Settings).
  • separation - Real - The spacing between individual characters in the font.

Returns:

  • Asset.GMFont

struct_copy

Creates a duplicate of a given struct, preserving its properties.

Arguments:

  • struct - Struct - The struct object to copy.

Returns:

  • Struct

instance_create

Creates a new instance of the specified object at the current depth, with optional variable definitions and parent object assignment.

Arguments:

  • x - Real - The x-coordinate for the new instance.
  • y - Real - The y-coordinate for the new instance.
  • obj - Asset.GMObject - The object to create an instance of.
  • var_struct - Struct - A structure to initialise instance variables (optional, defaults to {}).
  • parent - Id.Instance - An instance to set as the parent for culling purposes (optional, defaults to noone).

Returns:

  • Id.Instance
Clone this wiki locally