Alarm on mouse button check question!

S

Stratos.la

Guest
I have an object that slows down time together with some other functions and up until now, i had it set to true on global mouse down (while its pressed) and false when released. but well it would be better for it to start after a few seconds. i did alarm[0] = room_speed * 2 in global_left_Down and in the alarm set the slow = true but it doesn't work! instead, it gets set to true on its own after 2 seconds.
 

BiTrunade

Member
You can have just the global mouse button pressed and check whether slow is true to trigger it.

GML:
If(slow) {
slow = false;
alarm[0] = room_speed*2;
}
And then in the alarm add
Code:
slow = true;
Remove the global mouse button released, as you won't need it.
 
S

Stratos.la

Guest
You can have just the global mouse button pressed and check whether slow is true to trigger it.

GML:
If(slow) {
slow = false;
alarm[0] = room_speed*2;
}
And then in the alarm add
Code:
slow = true;
Remove the global mouse button released, as you won't need it.
no it doenst work mabe because i set the way time slows down in my step event?
GML:
if (slow)
 {
    if (global.spdScale > spdSlow) {
        global.spdScale -= 0.1;
    } else {
        global.spdScale += 0.1;
    }
} else if (!slow) {
    if (global.spdScale != 1) global.spdScale += 0.1;
}
 

BiTrunade

Member
no it doenst work mabe because i set the way time slows down in my step event?
GML:
if (slow)
{
    if (global.spdScale > spdSlow) {
        global.spdScale -= 0.1;
    } else {
        global.spdScale += 0.1;
    }
} else if (!slow) {
    if (global.spdScale != 1) global.spdScale += 0.1;
}
Is slow a Boolean variable or is it a real number?

Can you please show us the code for the mouse events and how slow is handled?
 
Last edited:
S

Stratos.la

Guest
create event
GML:
slow = false;
spdSlow = 0.2;
global.spdScale = 1;
Step event
GML:
if (slow)
 {
    if (global.spdScale > spdSlow) {
        global.spdScale -= 0.1;
    } else {
        global.spdScale += 0.1;
    }
} else if (!slow) {
    if (global.spdScale != 1) global.spdScale += 0.1;
}
left down and left released had false and true. And yes its a boolean
 

BiTrunade

Member
create event
GML:
slow = false;
spdSlow = 0.2;
global.spdScale = 1;
Step event
GML:
if (slow)
{
    if (global.spdScale > spdSlow) {
        global.spdScale -= 0.1;
    } else {
        global.spdScale += 0.1;
    }
} else if (!slow) {
    if (global.spdScale != 1) global.spdScale += 0.1;
}
left down and left released had false and true. And yes its a boolean
Edit you mouse event:
GML:
If(!slow) {
slow = true;
alarm[0] = room_speed*2;
}
And make slow = false; in alarm 0.
 
S

Stratos.la

Guest
that works the other way around. it slows down the time immediately and sfter 3 secons sets it to false. besides that my enemies start out slowed down and then start walking normaly. i tried some variations but still nothing.
 

BiTrunade

Member
that works the other way around. it slows down the time immediately and sfter 3 secons sets it to false. besides that my enemies start out slowed down and then start walking normaly. i tried some variations but still nothing.
Did you see the updated answer? I apologise I had to edit it.
 
S

Stratos.la

Guest
if you mean this one
GML:
if (global.spdScale > spdSlow) {

        global.spdScale -= 0.1;

    } else {

        global.spdScale += 0.1;

    }
i saw it and tried it but still nothing. Should i assume its because of the global mouse pressed event? could that mess it up? its not set in mouse down but in global mouse down
 

BiTrunade

Member
this one??
Yes, this one.

It doesn't matter, it triggers the slow on when pressed and toggle it on again in alarm 0.

I still don't understand (or see) what you are trying to achieve, but this code works for toggling slow on and off with interval between them.
 
S

Stratos.la

Guest
well the game is for android and when the player touched the screen and keeps it touched it slows down time for him to draw on the screen actions like spells and such so when he releases the finger from the screen everything goes back to normal and he can hit the enemies by tapping them.But since the way i initialy had it even by tapping the enemies the slow because true so it looks like a glitch thus i thought i could delay the slowing down time by 2 seconds after you place your finger on the screen and set it to false immediately once you lift the finger

edit. the mouse events are set to global since the object that controls all that doesnt have a sprite! it spawns on room start and handles the time slowing and the gestures by drawing
 

BiTrunade

Member
well the game is for android and when the player touched the screen and keeps it touched it slows down time for him to draw on the screen actions like spells and such so when he releases the finger from the screen everything goes back to normal and he can hit the enemies by tapping them.But since the way i initialy had it even by tapping the enemies the slow because true so it looks like a glitch thus i thought i could delay the slowing down time by 2 seconds after you place your finger on the screen and set it to false immediately once you lift the finger

edit. the mouse events are set to global since the object that controls all that doesnt have a sprite! it spawns on room start and handles the time slowing and the gestures by drawing
I get it now, you would have to initialize a new variable for toggling slow on and off.

In the create event add another variable
GML:
can_slow = true;
in the Global Mouse Event add
Code:
If(can_slow) {
slow = true;
can_slow = false;
alarm[0] = room_speed*2;
}
In the alarm[0] add
Code:
can_slow = true;
And now you would HAVE to add Global Mouse Released. Add this code to it
Code:
slow = false;
This should do the work, please try it and tell me.
 
S

Stratos.la

Guest
yup, that did it! although i do see some lagging similar to time slow when the enemies spawn but maybe its my laptop doing it. I'm gonna test it again when i get home on my computer which is build for game dev! thank you very much! i'll do tell again later today!
 

BiTrunade

Member
yup, that did it! although i do see some lagging similar to time slow when the enemies spawn but maybe its my laptop doing it. I'm gonna test it again when i get home on my computer which is build for game dev! thank you very much! i'll do tell again later today!
You are very welcome. Happy to help.
 
Top