Spawning Object in "On Destroyed" spawns on another layout

0 favourites
  • 4 posts
From the Asset Store
Plugin Transition Layout C3. Layout opening and closing animation for C3. Quickly set up transitions between lay
  • Problem Description

    I got objects that spawn other objects when they are destroyed. For example, explosion after grenade, monsters that spawn smaller monsters upon death, etc. I spawn these objects in "On Destroyed" event, and I see that when I change the layout, the objects spawned during "On Destroyed" will appear in the next layout.

    Attach a Capx

    Description of Capx

    The capx has a black box and a red box.

    The black box got a drag and drop behavior. Left click to move it around.

    Middle click on black box to destroy it, which will leave a red box behind. (using "On Destroyed" event, apparently)

    Right click creates another black box.

    Press R to restart layout. You will see that upon restart, red boxes will appear in all positions of where all the black boxes were.

    Steps to Reproduce Bug

    Just create objects during "On Destroyed" event and change layout, and you will see this bug.

    Expected Result

    Objects that are created in "On Destroyed" event should not appear in the next layout.

    Affected Browsers

    • Chrome: YES
    • FireFox: YES

    Operating System and Service Pack

    Win7 64 bits

    Construct 2 Version ID

    r173 64bits

    I used "On Destroyed" in various places: a big slime monster could spawn more smaller slime monsters upon death, and smaller slime monsters also spawn the liquid explosive upon death. The liquid explosive leaves trace of liquid upon destroyed. Everything is fine if the player killed everything and nothing invokes "On Destroyed" event upon layout changing, but if some objects are not killed, something will pop up in the next layout. That's bad.

    One more thing: I also noticed that sometimes the object count becomes negative/incorrect in the game I am developing. During layout changing, the game stutters a bit, given there are hundreds of objects in the layout. And sometimes, the object count is incorrect.

    I have been trying to reproduce the negative object count on a smaller scale capx, but I couldn't reproduce it. All these "On Destroyed" events in my project also have sound effects played during "On Destroyed" and they stutter quite a bit upon layout changing. I am not sure whether frame stuttering is related to negative object count or not. Yet I only see object count becoming incorrect upon layout changing (ie. restart layout) only. In fact, by simply restarting a layout in my project once or twice, I already see object count number decreasing upon restart. Sometimes I see it on the first restart, sometimes on the second, sometimes third.

    I have also tried remove "included event sheets" that are related to these events of monsters, etc., and I see that the object count number is correct. But like I said, I couldn't reproduce this on a smaller scale yet. Still, could you please investigate what could go wrong here? Thank you.

  • I have also looked around the forums and found a similar bug report for my second issue: negative-objectcount_t91148?&hilit=On+Destroyed+negative+objectcount . R0J0hound provided the capx: ... count.capx

    I have tried this capx on my r173, and the "object count becomes negative" issue still hasn't been fixed.

    This could also be related, as this capx also spawns object in "On Destroyed" event and also restarts layout as well.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Closing as won't fix: objects are destroyed at the end of the layout (when it is restarted or goes to a different layout), and so you are creating more new objects at the end of the layout. I think it's reasonable that these objects you created continue to exist. If you don't want them to exist, don't create any more objects after changing layout (set a global variable flag or some such).

  • Hey, Ashley, thank you for your suggestion. It does fixed this issue. Incorrect object count is also no longer an issue as well.

    Thank you for your assistance as always.

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