This function creates a sprite view of the referenced sprite with the specified image index within the current debug section.
A reference, created using ref_create, is passed for both the sprite and the image index.
NOTE This debug control spans two columns.
dbg_sprite(sprite_ref, image_index_ref[, label, width, height]);
Argument | Type | Description |
---|---|---|
sprite_ref | Reference | A reference to a variable holding a sprite index, created using ref_create |
image_index_ref | Reference | A reference to a variable that holds the image index to show, created using ref_create |
label | String | OPTIONAL The label to display next to the sprite view |
width | Real | OPTIONAL The width to draw the sprite at. If no height value is provided in the next argument, the sprite's aspect ratio is maintained and height is adjusted accordingly. Defaults to the sprite's width. |
height | Real | OPTIONAL The height to draw the sprite at. If no width value is provided in the previous argument, the width is kept at its original value. Defaults to the sprite's height. |
N/A
Create Event
ref_to_sprite = ref_create(self, "sprite_index");
ref_to_image_index = ref_create(self, "image_index");
dbg_sprite(ref_to_sprite, ref_to_image_index);
The above code sets up a basic sprite view for an instance's sprite. The code is added to an event that is only executed once, e.g. the Create event.
First, two references are created using ref_create: one to the current instance's sprite_index variable (stored in ref_to_sprite), the other to the instance's image_index variable (stored in ref_to_image_index). Next, the sprite view is created using dbg_sprite, with arguments the two references created before.
The sprite's frame will change based on the value of image_index, and so is drawn animated in the sprite view. The sprite will also change whenever the instance's sprite_index changes.