Legacy GM [SOLVED] About making an announcement

R

Ryzzax

Guest
Hi all!

So, here's my problem: In my game, I have a level-up system which depends on how much points we have (Example: if points >= 25, Level = 1) And so, I want to make an announcement for it like, "You just upgraded to Level 1 !", for example. But, the way I'm doing is:
Code:
//step Event

if (global.level == 1)
{
    instance_create(x,y,obj_info);
}
(In the 'obj_info' instance, there is the draw to display the massage to the right place on the screen.)
The problem is that the message stays there until I level up again, to level 2. So, in the 'obj_info', I put a create event and put 'Alarm[0] = 180;' and then, in the alarm[0] I put instance_destroy(); (self, ofc).

But, still doesn't work, the message is still there. I guess this is because it's a step event, and because I'm level 1, it keeps creating the instance 'obj_info' until my level changes.

So, how should I do it? Should I put it in another event then step. Or, is there a line of code to say in the step event "Only do this action once"?

Thank you to anyone in advance that helps me out! :)
 
Don't create this object in the step event.
Create this object once, in your game room on startup. In the step event of the obj_info object, have code that writes the message based on an alarm. E.G. when alarm gets to zero, stop writing the message.
 
You can easily solve this with one extra variable :) Something like "next_level", used like this:
Code:
if (global.level == 1 && next_level == 1)
{
instance_create(x,y,obj_info);
next_level++;
}
This will make sure that the instance is only created this one step where the level is "new" :) Although what stops you from creating obj_info in the code where you level up/set the new level?
 

zircher

Member
[major edit] To run with Bless's code... This will call instance create once per level up. It obj_info reads global.level, you can use the object over and over again.
Code:
if (global.level == next_level)
{
  instance_create(x,y,obj_info);
  next_level++;
}
I'm going to assume that obj_info has an alarm and destroys itself. Otherwise, look at creating the obj_info in the room and using instance activate/de-activate.
 
Last edited:
R

Ryzzax

Guest
Don't create this object in the step event.
Create this object once, in your game room on startup. In the step event of the obj_info object, have code that writes the message based on an alarm. E.G. when alarm gets to zero, stop writing the message.
Sorry but, what is 'E.G.'? Is it an event?
 
Top