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

SOLVED Sprite moving too fast

Hi everyone :)
I have an object that is going to fast through the frames. I checked to make sure the speed was low (I set it to two) and I tried
setting image_speed =2. Still they are too fast.
I'm not sure what code I should post? The main object doesn't really effect the image_speed and
the spawning code doesn't really effect anything other than instantiating. I looked at the sprite code
and it is set to 2 for speed so that shouldn't be an issue.

TW
 
J

james5795

Guest
Try changing the image speed to 1, and lowering the frame rate to around 15 fps. If neither of those help at all, you are either using the wrong sprite or something is broken.
 

kburkhart84

Firehammer Games
Since you are setting the image_speed to control how fast the frames move...you want to remember that there is a variable called image_index. This variable determines which frame of your sprite is currently being drawn(using just the integer part). And the image_speed is how much to add to the image_index per frame. So, setting it to 2 means that each frame/step in your game the variable increases by 2, therefore it skips 1 frame. You probably want to set it to something like 0.25 or maybe even 1, depending on the animation itself and what room speed you are using.
 

kburkhart84

Firehammer Games
Try changing the image speed to 1, and lowering the frame rate to around 15 fps. If neither of those help at all, you are either using the wrong sprite or something is broken.
I had forgotten that the new sprite editor does indeed have this setting. I would recommend setting image_speed to one and then controlling the speed of the animtion there in that preview of the sprite editor(since that affects the game instead of just the preview). Then, if you wanted to make the animation go slower or faster, you could adjust image_speed around the nice even value of 1.
 

kburkhart84

Firehammer Games
Does the sprite editor preview show it moving at the speed you want it to move at? If so, then you have likely changed the image_speed in your code to something other than 1. You don't want to set both to 2 because then it will double the speed. Just set the sprite editor one to the right speed using that preview and then don't set image_speed at all unless you are changing the speed on purpose in your game for some reason.
 

Lukan

Gay Wizard Freak
image_speed should be set to 1
image_speed is is a multiplayer for the speed you have the animation to play at in the sprite editor.
So it you have one speed set in the sprite editor, setting image speed to 2 means it's running twice as fast.
 
Set the image_speed to 1 and the 1 in the sprite editor. Not sure what to do.

GML:
if (hp <= 1000)
{
    if (image_alpha >= 0)
    {
        image_alpha -= 0.01;
    }
    if (image_alpha <= 0)
    {
        //GO ONTO THE NEXT LEVEL
        show_debug_message("Global Game Map is " + string(global.game_map));
       room_persistent = false;
    }
    
}

if (hp <= 0)
{
    
    if hp <= 0 //And whatever other conditions / timers / effects etc etc that need to finish before transitioning
    {
        if !room_change
        {
            room_change = true;
            scr_transition();
        }
    }
    
    
       room_persistent = false;
    
    
    
    //}
    
    inst = instance_create_depth(x, y, -1100, FrankensteinObject)
    
    with (BrainMaster)
    {
        sprite_index = FrankensteinYouWin;
        //audio_stop_sound(ConsumingShadows);
        if (global.game_win_flag == false)
        {
            audio_stop_all();
            //audio_play_sound(WinMusic, 10, false);
            global.game_win_flag = true;
            
            
        }
            
            
        if (!instance_exists(FrankGhostObject) && global.frank_ghost_flag == false)
        {
            instance_create_depth(x, y-300, -1800, FrankGhostObject);
            global.frank_ghost_flag = true;
            with (FrankensteinIdleObject)
            {
                image_index = 0;
            }
        }   
    }
 

kburkhart84

Firehammer Games
The image_speed in the code should be 1. The values in the sprite editor can be adjusted while literally looking at the animation, so there is no reason why you should have any issue figuring out the correct value there. You have a literal preview of the sprite there. If it is too fast, change the number until it is slower and eventually the exact speed you want. Then, don't change the code at all. In fact, there is no reason to even have code modifying the image_speed unless you purposefully want the animation to change speed during the game.
 

xS89Deepx

Member
sprite_index = spr_Spiderman;
image_speed=0.5;
If your room running at 120fps, it might be causing the problem.
 
Last edited:

kburkhart84

Firehammer Games
sprite_index = spr_Spiderman;
image_speed=0.5;

this is what i use for few sprites xD
We have been recommending going against using the image_speed variable since the sprite editor now has a nice preview for setting the speed, and the sprite as used in game will respect that speed as well as long as you leave image_speed variable alone.
 
Top