Are Functions inherently global?

0 favourites
  • 4 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.
  • Hi Ashley, I've noticed that Functions can be called even if not included in the current event sheet.

    Does this mean all functions are global, and checked every tick?

    Tagged:

  • Yes, all functions are global. It's easy to check: just create a project, add a second event sheet, add a function, and see if you can call it in the other event sheet. You can. I noticed the manual entry does not specifically state that though, so I added a note to point that out.

    But no, being global does not mean it has to be checked every tick. Like triggers, they only run when they are called.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you for clarifying that Ashley.

    Is it possible you can describe the process on how Event Triggers and Functions are handled? I know they are skipped, which is great, but to what extent?

    I've been experimenting on a new optimization technique I've been doing on an existing mobile project, and I've found that moving all utility functions to JavaScript has dropped my mobile CPU usage from +-60% to +-32%, and removed stuttering janks which I've only recently discovered how to specifically solve.

    Now, I only use the event sheet for every ticks and event listeners, which makes the project feel lightweight.

    However, amazingly, I've found that moving functions to a non-included event sheet does the similar performance improvement.

    I previously mistakenly thought the performance issue was the GPU, since the CPU usage is not that high and I've not seen a way to profile the GPU usage, and lowering the fill-rate was improving the experience so it easily disguised the issue.

    Fortunately, it seems it was just the accumulated event count causing the CPU usage, which is understandable given the limited performance capability of mobile CPUs.

    I would appreciate if you could explain here how the event triggers and functions are skipped, so that we can better understand how we can make better use of the event sheet.

    Thank you!

  • The engine just completely ignores the event sheet that functions are on. So there is no technical reason why moving functions to a different event sheet would affect anything. I would guess you actually changed something else which affected performance.

    I don't know what more to say about functions and triggers. They do nothing, except run when they run. Only ordinary events are checked every tick.

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