You are not logged in.
Draw a sprite and animate it at the same time.
Though really all you half to do is
Create Event:
Image = 0;
Draw Event:
draw_sprite(spr_eyes, Image, x, y);
Image+=0.4;
But this is still neat I think.
/// draw_sprite_animate(sprite, subimg, spd, x, y, [xscale], [yscale], [rot], [colour], [alpha]);
//
// Draw sprite and animate it, returns the next subimg
//
// Usage:
//
// So if you need to draw eyes on your player and anmate them
//
// Create Event:
// eyes_frame = 0;
//
// Draw Event:
// eyes_frame = draw_sprite(spr_eyes, eyes_frame, 0.4, x, y-10);
//
//
// sprite The index of the sprite to draw.
// subimg The subimg (frame) of the sprite to draw (image_index or -1 correlate to the current frame of animation in the object).
// spd The rate that the subimg (frame) changes. It may be any number and decimal above 0.
// x The x coordinate of where to draw the sprite.
// y The y coordinate of where to draw the sprite.
// rot The rotation of the sprite. 0=right way up, 90=rotated 90 degrees counter-clockwise etc...
// colour The colour with which to blend the sprite. c_white is to display it normally.
// alpha The alpha of the sprite (from 0 to 1 where 0 is transparent and 1 opaque).
//
// You can only animate frames forward, if you want to do it backwards you can modify the return for this script
//
/// GMLscripts.com/license
{
var spr = argument[0];
var subimg = argument[1];
var spdimg = argument[2];
var xx = argument[3];
var yy = argument[4];
// Optional Arguments
if (argument_count>5) var xscale = argument[5];
else var xscale = 1;
if (argument_count>6) var yscale = argument[6];
else var yscale = 1;
if (argument_count>7) var rot = argument[7];
else var rot = 0;
if (argument_count>8) var colour = argument[8];
else var colour = c_white;
if (argument_count>9) var alpha = argument[9];
else var alpha = 1;
// Draw Sprite
draw_sprite_ext(spr, subimg, xx, yy, xscale, yscale, rot, colour, alpha);
// Return next subimg of the sprite
return (subimg+spdimg)%sprite_get_number(spr);
}
Here's the same one but useful if you want to animate backwards, also requires the wrap script.
/// draw_sprite_animate(sprite, subimg, spd, x, y, [xscale], [yscale], [rot], [colour], [alpha]);
//
// Draw sprite and animate it, returns the next subimg
//
// This requires the wrap script from here:
// http://www.gmlscripts.com/forums/viewtopic.php?pid=3890#p3890
//
// Usage:
//
// So if you need to draw eyes on your player and anmate them
//
// Create Event:
// eyes_frame = 0;
//
// Draw Event:
// eyes_frame = draw_sprite(spr_eyes, eyes_frame, 0.4, x, y-10);
//
//
// sprite The index of the sprite to draw.
// subimg The subimg (frame) of the sprite to draw (image_index or -1 correlate to the current frame of animation in the object).
// spd The rate that the subimg (frame) changes. It may be any number and decimal above 0.
// x The x coordinate of where to draw the sprite.
// y The y coordinate of where to draw the sprite.
// rot The rotation of the sprite. 0=right way up, 90=rotated 90 degrees counter-clockwise etc...
// colour The colour with which to blend the sprite. c_white is to display it normally.
// alpha The alpha of the sprite (from 0 to 1 where 0 is transparent and 1 opaque).
//
// With this script you can also animate frames forwards and backwards by setting the speed to a negative number
//
/// GMLscripts.com/license
{
var spr = argument[0];
var subimg = argument[1];
var spdimg = argument[2];
var xx = argument[3];
var yy = argument[4];
// Optional Arguments
if (argument_count>5) var xscale = argument[5];
else var xscale = 1;
if (argument_count>6) var yscale = argument[6];
else var yscale = 1;
if (argument_count>7) var rot = argument[7];
else var rot = 0;
if (argument_count>8) var colour = argument[8];
else var colour = c_white;
if (argument_count>9) var alpha = argument[9];
else var alpha = 1;
// Draw Sprite
draw_sprite_ext(spr, subimg, xx, yy, xscale, yscale, rot, colour, alpha);
// Return next subimg of the sprite
return wrap(subimg+spdimg,0,sprite_get_number(spr));
}
But only other thing I can think of making another neat script that may be more useful is one that lets you animate only a range of your sprite's subimgs. So here's one that does that too. Only issue is that I'm not sure why it flickers when you animate it backwards when starting at the middle frame and end at the last frame. also requires the wrap script too.
/// draw_sprite_animate_part(sprite, subimg, start, end, spd, x, y, [xscale], [yscale], [rot], [colour], [alpha]);
//
// Draw sprite and animate it only within a starting and ending frame,
// returns the next subimg
//
// This requires the wrap script from here:
// http://www.gmlscripts.com/forums/viewtopic.php?pid=3890#p3890
//
// Usage:
//
// So if you need to draw eyes on your player and anmate them
//
// Create Event:
// eyes_frame = 0;
//
// Draw Event:
// eyes_frame = draw_sprite(spr_eyes, eyes_frame, -0.4, x, y-10);
//
//
// sprite The index of the sprite to draw.
// subimg The subimg (frame) of the sprite to draw (image_index or -1 correlate to the current frame of animation in the object).
// start The starting frame
// end The enging frame
// spd The rate that the subimg (frame) changes. It may be any number and decimal above 0.
// x The x coordinate of where to draw the sprite.
// y The y coordinate of where to draw the sprite.
// rot The rotation of the sprite. 0=right way up, 90=rotated 90 degrees counter-clockwise etc...
// colour The colour with which to blend the sprite. c_white is to display it normally.
// alpha The alpha of the sprite (from 0 to 1 where 0 is transparent and 1 opaque).
//
// This script flickers when animating backwards (A spd that's negative).
//
/// GMLscripts.com/license
{
var spr = argument[0];
var subimg = argument[1];
var minimg = argument[2];
var maximg = argument[3];
var spdimg = argument[4];
var xx = argument[5];
var yy = argument[6];
// Optional Arguments
if (argument_count>7) var xscale = argument[7];
else var xscale = 1;
if (argument_count>8) var yscale = argument[8];
else var yscale = 1;
if (argument_count>9) var rot = argument[9];
else var rot = 0;
if (argument_count>10) var colour = argument[10];
else var colour = c_white;
if (argument_count>11) var alpha = argument[11];
else var alpha = 1;
// Draw Sprite
draw_sprite_ext(spr, subimg, xx, yy, xscale, yscale, rot, colour, alpha);
// Return next subimg of the sprite
return wrap(subimg+spdimg,minimg,maximg);
}
Last edited by KurtBlissZ (2016-11-21 22:24:11)
Offline