GMLscripts.com

Discuss and collaborate on GML scripts
Invert

You are not logged in.

#1 2023-03-07 18:20:15

helloitscrash
Member
Registered: 2023-03-07
Posts: 2
Website

draw_sprite_animated

This is much simpler to use than creating a bunch of different variables to use for one function, plus it all takes place in one line.

Expand/// draw_sprite_animated(spr, _x, _y);
//
//  Draw an animated sprite at an x and y coordinate, based on its original image speed as set in the sprite editor.
//  spr     The sprite you want to draw
//   _x     The x position to draw the sprite
//   _y     The y position to draw the sprite
//
//  Unlike draw_sprite(), there is no space for a sub-image; that is calculated automatically with the script
//
/// GMLscripts.com/license
function draw_sprite_animated(spr,_x,_y) {
  var _t = (current_time/1000) * sprite_get_speed(spr);
  return draw_sprite(spr,_t,_x,_y);
}

Last edited by helloitscrash (2023-03-07 18:20:35)

Offline

#2 2023-03-09 18:48:21

gnysek
Member
Registered: 2011-12-29
Posts: 36

Re: draw_sprite_animated

Shouldn't it also take "sprite_get_speed_type" into account?

Offline

Board footer

Powered by FluxBB