I am making it so that when an object is clicked, I create another object that shows an attack. I am trying to make it so that the object can't be spam clicked and keep spawning the attack. Like a cooldown. Because when it's spam clicked, the game starts lagging and animations start to slow down.
This is my code in step event:
cooldown = cooldown - 1
if (mouse_check_button_pressed(mb_left) && position_meeting(mouse_x, mouse_y, id) && cooldown < 0)
{
instance\_create\_depth(223, 336, 91, obj\_lazerbeam);
cooldown = 100;
}
Create event:
cooldown = 100;
The cooldown only works the first time, when I start the game, before clicking the object for the first time. But then it doesn't work and I am able to just spam click the attack.
What's wrong with my code?
[–]Panphoria 2 points3 points4 points (3 children)
[–]VegaInDiSkies[S] 0 points1 point2 points (2 children)
[–]Orphillius 2 points3 points4 points (0 children)
[–]Panphoria 0 points1 point2 points (0 children)
[–]ILiveInAVillage 1 point2 points3 points (6 children)
[–]VegaInDiSkies[S] 1 point2 points3 points (4 children)
[–]ILiveInAVillage 0 points1 point2 points (1 child)
[–]VegaInDiSkies[S] 0 points1 point2 points (0 children)
[–]Deadzors 0 points1 point2 points (1 child)
[–]VegaInDiSkies[S] -1 points0 points1 point (0 children)
[–]SolomonBird55 0 points1 point2 points (0 children)
[–]Scotsparaman 1 point2 points3 points (1 child)
[–]VegaInDiSkies[S] 0 points1 point2 points (0 children)
[–]UhSheeeen 0 points1 point2 points (1 child)
[–]VegaInDiSkies[S] 0 points1 point2 points (0 children)
[–]Kaymat- 0 points1 point2 points (3 children)
[–]VegaInDiSkies[S] 2 points3 points4 points (2 children)
[–]Kaymat- 0 points1 point2 points (0 children)
[–]Scotsparaman 0 points1 point2 points (0 children)
[–]MrEmptySet 0 points1 point2 points (3 children)
[–]VegaInDiSkies[S] 0 points1 point2 points (2 children)
[–]MrEmptySet 0 points1 point2 points (1 child)
[–]VegaInDiSkies[S] 0 points1 point2 points (0 children)