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

GameMaker Alarm times different between objects

F

Frolacosta

Guest
I have a 2 object's where I am setting an alarm using the following code in the Create event:

Code:
alarm[0] = 1;
Within alarm 0 I am doing the following:


Code:
if(image_alpha == 0) {
    instance_destroy();
}

image_alpha -= 0.1;
alarm[0] = game_get_speed(gamespeed_fps);
The idea being, the object will fade out and be destroyed within 10 seconds (minus 0.1 from image_alpha every second).

One of the objects with this code fades out and disappears within 1.5 seconds, whereas the other disappears within 10 seconds as expected.

Can anyone explain why this might be? Or if there are other variables which can affect the timer within alarms, or game_get_speed(gamespeed_fps) between objects?
 
I think the frame calculations you are pulling from game_get_speed(gamespeed_fps)
may fluctuate because it refers to the calculations and not the room speed or what have you. What happens if you use something other than game_get_speed(gamespeed_fps) to set alarm[0]?
Shoot, try alarm[0]=1 for example and see if it still differs.
 
Last edited:
S

Stratadox

Guest
In order to be consistent with the time frame within your game, the way to set an alarm to one second is by using room_speed, as in

alarm[0] = room_speed;

or, for say 10 seconds,

alarm[0] = room_speed * 10;



If you need to be more exact, alarms might not be the best solution. In such case I'd consider storing the start time as precise as possible, and comparing that to the current time as often as possible until current_time>= start_time+ 1
 
Top