Scripting "beforelayoutstart" event only emits once despite revisiting layout. Alternatives?

0 favourites
  • 5 posts
From the Asset Store
Change the size and position of everything without calculating anything!
  • Hi all,

    First off, thanks for all of the support on the forums! I'll note that I searched forum posts and documentation and still having questions.

    I'm having a little trouble understanding and coming up with an elegant solution for a scripting way to trigger an event at the start of the layout when the layout is loaded multiple times in a cyclic pattern. The existing "beforelayoutstart" event in ILayer empirically only run the first time the layout is started, but not if I go in the following pattern:

    MenuLayout -> LevelLayout (event works here) -> ScoreLayout -> LevelLayout (event does *not* work here)

    It's not very clear from the description in the ILayer documentation, which counterintuitively (unless I'm doing something wrong here) that "beforelayoutstart" event is *"Fired when the layout starts. "beforelayoutstart" fires just before On start of layout, and "afterlayoutstart" fires just after"* especially since the event sheet On start of layout does fire when I load LevelLayout a second time. It'd be nice to have documentation clarify either way.

    Assuming only firing once before the *first* start of the layout is how it's intended (and I'm just not grossly misunderstanding events), I looked for other solutions:

    1. [Doesn't work] Calling functions concerning objects on LevelLayout in the same function as my move to layout call. This doesn't work because the move to layout is performed at the end of the tick after all other code. Unless I'm missing something here too.

    2. [Seems very inefficient] Storing a "layoutLastTick" variable and any functionality to be run on next layout, comparing current to previous layout every tick to decide whether or not to run.

    3. [Went with this, but ugly] Using the event sheet solely for an actual "On start of layout" and then calling script inside. I imagine this is in reality as inefficient as solution two since the sheet runs each tick.

    Anyone else come up with better solutions? Am I just misunderstanding the use of "beforelayoutstart" event or alternatives?

  • beforelayoutstart does fire just before 'On start of layout', so it should be firing whenever that triggers, including when returning to a layout already visited. Could you share a project demonstrating your code? Perhaps there is a mistake that has confused you. For example these events fire on ILayout, and you talk about ILayer which is unrelated here, so it seems likely you mixed up something.

  • You can write your own discord, I will try to help you.

  • Thanks! Looks like things are working fine on a simple project, so there must have been something else suppressing my logs or unsubscribing to the event.

    The ILayer in the post was just a typo.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Sorry for the false alarm.

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