Question about global and local variables?

0 favourites
  • 6 posts
From the Asset Store
Globals 2.0
$3.99 USD
Globals 2.0 stores and group variables. You can also load and save data (variables) from/to JSON files.
  • If you create an event for a family using a global or local variable, and many different object instances from that family activate that event at the same time, do they all access just ONE same variable for all the activated events, or do they each create a separate variable instance for themselves?

  • There is only one variable 'instance', a Family has no special effect on a variable. You'd need to have the variable on the Family for each member instance to have its own value. Keep in mind also that local (non-static) variables are reset every tick.

  • thanks. But I have another question.

    Can many events be activated at the same time? For example there are 3 collisions,A collides with B, C collides with D, E collides with F, if I time them all at exactly the same time, will they all access the Event "On collision with object" at the same time? Or will they be put in a queue and take turn processing it?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • thanks. But I have another question.

    Can many events be activated at the same time? For example there are 3 collisions,A collides with B, C collides with D, E collides with F, if I time them all at exactly the same time, will they all access the Event "On collision with object" at the same time? Or will they be put in a queue and take turn processing it?

    You will have different 'on collision' events for each object type(s), and they will run from top to bottom in the event sheet. Or if they are in a Family then you can do it in one event.

  • All though the computer can run really fast, it can not do more than 1 thing at a time. If an event fires 3 times at the exact same moment, they will happen one after another, thus the instance variable can be altered each time and work fine.

  • thanks. And another question.

    Say, I use a loop, for example, a while loop.

    On Monster collides with ObjectA ==> subtract Monster.Damage from ObjectA.HP

    while(ObjectA.HP>0)

    I have Monster1 hit ObjectA, the loop occurs. Then, I create another Monster2 and it hits ObjectA, BEFORE the first loop finishes. How will the Event be resolved now? Will the first loop finishes and the 2nd starts, or will they take turn damaging ObjectA?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)