• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

draw_sprite_ext

E

Endless

Guest
Hello everyone. I was messing with this option and i have two draw_sprite_ext. One for the player body, with facing, and no sprite animation. In second, i want to add legs for the player but how to animate it? The legs show when i move, but doesn't animate. Thanks in advance. :)

Code:
//Body
draw_sprite_ext(sprite_index, 0, x, y, image_xscale, image_yscale, Facing, image_blend, image_alpha);

//Legs
if speed > 0 {
    draw_sprite_ext(spr_legs, image_index, x, y, image_xscale, image_yscale, Facing, image_blend, image_alpha);
}
 

obscene

Member
The second argument is for the subimage You can just use a custom variable and then increase it every step. If you use image_index as the variable it depends on image_speed to increase.
 
R

Rafsun82

Guest
Check if you used "image_speed = 0" anywhere in that object.
 
The reason why your leg sprite isn't animating is because, presumably, the body sprite, which is in 'sprite_index', only has a single sub image. When you try to use 'image_index' in the second draw call, to draw the legs, it's using the data from the body sprite. So, since there is only a single sub image, your leg sprite does not appear to animate, because 'image_index' will always be '0'. To fix this, you'll have to do as @obscene suggested. A rough example:

Create Event:
Code:
legs_index = 0;
Step Event:
Code:
legs_index += image_speed;

if (legs_index >= sprite_get_number(spr_legs))
{
    legs_index -= sprite_get_number(spr_legs);
}
Draw Event:
Code:
// Body code omitted

//Legs
if speed > 0 {
   draw_sprite_ext(spr_legs, legs_index, x, y, image_xscale, image_yscale, Facing, image_blend, image_alpha);
}
 
E

Endless

Guest
Wow! This works great!!! THANK YOU!!!
Can you tell me also how to adjust the animation speed for legs because it's now about 60fps because the room speed is 60fps?
 
E

Endless

Guest
I was thinking it would not work. But i simply added in step event image_speed = 1 and is all alright! Thanks again. This is solved! :)
 
Top