• 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!

Does a sprite's speed need to be a multiple of its number of sub-images? [SOLVED]

R

Robzoid

Guest
My friend and I are making our first game. He says that a sprite's speed (in frames per second) needs to be a multiple of the number of the sprite's sub-images. For instance, a sprite with 7 sub-images would need to have a speed of 7, 14, 21, etc. Is this true? The sprite seems to work just fine in the game if i choose a non-multiple (e.g. speed of 10 with 7 sub-images) for the sprite's speed, but I don't know if there's some reason behind this that I'm not aware of. Is there any benefit to doing this?


upload_2018-7-4_11-25-31.png
 
D

dugtrioramen

Guest
My friend and I are making our first game. He says that a sprite's speed (in frames per second) needs to be a multiple of the number of the sprite's sub-images. For instance, a sprite with 7 sub-images would need to have a speed of 7, 14, 21, etc. Is this true? The sprite seems to work just fine in the game if i choose a non-multiple (e.g. speed of 10 with 7 sub-images) for the sprite's speed, but I don't know if there's some reason behind this that I'm not aware of. Is there any benefit to doing this?


View attachment 19407
If could be any number you want, in fact making it seven would make it slightly uneven

That speed basically says
After every room_speed/speed steps, increment the frame

So if your speed is 7 and your room speed is 30
The frame increments after every 4.285714 steps.
If your speed was 10, it would increment after every 3 steps.
You can tell which one would produce a more even effect

The only advantage to making the speed a multiple of the amount of frames is that it would make the whole animation run in terms of seconds.
If your speed was 7, the whole animation finishes in one second
If your speed was 14, the whole animation finishes in half a second
If your speed was 21, a third of a second

Unless you want the animation to run based on seconds, making the speed a multiple isn't advantageous
 
M

MirthCastle

Guest
Also - The image_speed you set in code is a multiple of the speed you set in the sprite editor.

Examples:
If I have image_speed set to 1 in the create event (or anywhere else), and I have the speed set to 15 in the sprite editor - the final animation speed will be 15.

If I have image_speed set to 2 in the create event (or anywhere else), and I have the speed set to 15 in the sprite editor - the final animation speed will be 30.

If I have image_speed set to 0.5 in the create event (or anywhere else), and I have the speed set to 15 in the sprite editor - the final animation speed will be 7.5.

For ease of use, I tend to just set the speed in the sprite editor to 1, and then use the image_speed variable to control the animation speed.

Hope that helps!
 
S

Spencer S

Guest
I actually the following:
Code:
//CREATE EVENT
imageSpeed = room_speed / 4;
imageSpeedTimer = 0;

//STEP EVENT
imageSpeedTimer += 1;
if imageSpeedTimer >=  imageSpeed {
    imageSpeedTimer = 0;
    image_index += 1;
    if image_index > sprite_get_number(sprite) {
        image_index = 0;
    }
}
This is probably more complicated than it should be, but its a really simple section of code that allows you to accurately control the speed at which the image transitions without ever worrying about what the speed in the sprite editor is. And this also works reliably well for animations that take multiple sprites (like equipment on the player).
 
R

Robzoid

Guest
Thanks for your help, everyone. I'm glad to hear I can set the speed to whatever without any issues coming up down the road.
 
I

icuurd12b42

Guest
the basic principle is you want enough images to provide smooth animation over the time you want so that it looks nice. (edit, removed misleading sentence)

The main concern is how long a single animation frame stays on screen and that all your animation are consistent in that aspect.... for example, if your baseline animation is your walk animation that last one second and it is 15 frames (well 14 since the last frame at a full second is frame 0 of the repeating walk animation) , that would make each animation frame last 2 game frames at 30 fps, 4 at 60. In a perfect world you want all your animations to stick to the screen for that number of game frames. so if an animation lasts for a short amount of time, it's number of frames still need to last for the same amount of screen time as your "baseline". You need to make sure your baseline allows some flexibility and enough frames for your artist to work with for your fastest animation. the artist should compensate with motion blur for fast animation, as opposed to force a fast animation to have more frames...
 
Top