GameMaker Animating draw_sprite_general

S

SmugMonster

Guest
Hey folks, so I can't get draw_sprite_general to draw an animated sprite. Here's what I've tried:
Code:
draw_sprite_general(beam_sprite,image_index,0,0,width,height,x+shift_x,y+shift_y,1,1,image_angle,c_white,c_white,c_white,c_white,1);
I also tried setting image_index to 0 and image_speed to 1 before that, and it didn't work. I also tried -1 instead of image_index, with the same results. The object that's running this code has a sprite with the same number of frames running at the same frame speed as the sprite I'm drawing. It's just drawing subimage 0 instead of animating.

I tried a manual workaround, but the last frame is hanging around a moment before disappearing, so that's not gonna work for me either.

Here's the code for that:

Code:
<Create>
frames = sprite_get_number(beam_sprite);
draw_frame_max = frames-1;


<End Step>
if (draw_frame < draw_frame_max)
{
    draw_frame++;
}


<Draw Event>
repeat(frames)
{
    draw_sprite_general(beam_sprite,draw_frame,0,0,width,height,x+shift_x,y+shift_y,1,1,image_angle,c_white,c_white,c_white,c_white,1);
}
 

MusNik

Member
It seems you forgot to set draw_frame to zero after animation has done a cycle?

Code:
if (draw_frame < draw_frame_max)
{
   draw_frame++;
}
else
{
   draw_frame = 0;
}
 

2Dcube

Member
Code:
repeat(frames)
{
   draw_sprite_general(beam_sprite,draw_frame,0,0,width,height,x+shift_x,y+shift_y,1,1,image_angle,c_white,c_white,c_white,c_white,1);
}
Also, you can leave out the repeat(). Here you are just drawing the same sprite several times on the same location. That looks exactly the same as drawing it once.
Unless you were leaving out some code that I am unaware of...
 
S

SmugMonster

Guest
It seems you forgot to set draw_frame to zero after animation has done a cycle?

Code:
if (draw_frame < draw_frame_max)
{
   draw_frame++;
}
else
{
   draw_frame = 0;
}
Nah, I only wanted it to cycle once. That said, this actually gives me a pretty neat result that I might use instead (the sprite is a lightning bolt animation and this gives it a nice flickery effect instead of just one zap, which I like)
 
Top