[r116] Changing layout and 'on destroyed'

0 favourites
  • 2 posts
From the Asset Store
Simplistic hyper-casual game with nature elements. Tap to switch between the 4 elements and reach a better score.
  • Link to .capx file (required!):


    Steps to reproduce:

    1. Press SPACE a few times to switch between layout 1 and 2.

    Observed result:

    Switching layout destroys all sprites on the layout 1, which calls their 'on destroyed' event, which then spawns new objects on layout 2.

    Expected result:

    Layout 2 should be empty, layout 1 should only have 4 visible sprites.

    Browsers affected:

    Chrome: yes

    Firefox: yes

    Internet Explorer: yes

    Operating system & service pack: Win 7 Home Premium x64 - SP 1

    Construct 2 version: r116

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • This particular .capx is impossible to resolve. When 'Sprite' is destroyed at the end of a layout, if the object it creates is then also destroyed because it's the end of the layout, then you get an infinite loop (Sprite2 is destroyed, which creates a Sprite which is destroyed, which creates a Sprite2 which is destroyed...)

    Therefore objects created when the layout is ending must not be destroyed.

    Workaround: use a global variable or flag to disable object creation when changing layout.

    Closing as won't fix.

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