[r103.2] Object list not updated in loop (?)

0 favourites
  • 10 posts
From the Asset Store
Fantasy Game includes more than 600 sound effects inspired by hit computer games like World of Warcraft and Diablo.
  • Hi, I wonder if it's by design or not, but I think that it's highly unexcpected.

    This capx just shows the problem in a simple way, but I stumbled upon this bug while working on a bsp tree algo.

    Basically I create 2 new sprites from existing ones each loop iteration. And only the first iteration works.

    So work around it I had to use the game loop instead to access an updated object list each iteration.

    If you're curious you end up with something like for now that.

    I think I read somewhere that objects are only created at the end of the event block containing the create action.

    But I think in loops cases it's too limiting.

  • This is because of the breaking change where created objects are not really created until the end of the next top level event. As a side effect the object count is not updated either until the end of the next top level event.

    I think this has been reported a couple of times now, which is reason enough to fix it, but unfortunately this will be another breaking change (since I am aware some projects already depend on the way it currently works).

  • Ashely

    Yeah I thought it was something like that. "The nex top level event" it's indeed very problematic for pseudo-random generation algorithms or any recursive stuff.

    Ideally, we should be able to pick and do overlap and parameter checks as soon as an object is created in the flow of actions.

    Hope you'll manage to work your magic on that (:

  • Ashley any word on this? I'm having a not very fun time trying to fix a game for a deadline.

  • It's only the object count that is affected. It's fixed for the next build, which should be out by the end of this week (hopefully tomorrow).

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ashley, so you are saying that you have only fixed the object count? Or has instance spawning/picking been reverted as well?

  • sqiddster - yes, only the object count - it really is hard in the engine to handle created objects differently without causing other projects to crash. It's a shame it had to change, if it had always worked this way the problem wouldn't be such a pain...

  • Ashley That's fine, just making sure. ;)

    Keep up the good work!

    I'm not quite sure how to deal with looped creation of objects now, however!

  • sqiddster - the best workaround is to make sure everything you do with an instance spawned in a loop is handled in subevents to that event only, rather than subsequent events. That should still work fine.

  • Ashley

    I showed you the issue in my capx with displaying the object.count value, but if I foreach the object it won't take the newly created ones as well. Is it because the foreach is based on the object count? (this question's aim is just to be sure that we won't end up with object count corrected but foreach still broken (: )

    and sqiddster, if you need something that is recursive, like

    on start of layout
    while
    object.count < limit
      foreach object
        -> create object

    you can distribute things over more than one tick

    object.count < limit
      foreach object
       -> create object

    (note that object:spawn is the same as foreach object -> create object)

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