Do unmet conditions reduce performance of loops?

0 favourites
  • 5 posts
From the Asset Store
For Adventure, Action, Heroes, Sci-fi and Action-RPG games.
  • I have a few "for each" loops, and I also have a condition to check whether or not a tween is still running. If the tween isn't running, would this improve performance, or does the game still have to check the "for each" loop? Is there a way of disabling loops when an instance of an object is no longer needed to be tested (in this case, I have for each loops to make play sound effects , but when the sprite isn't moving, it wont move any more, so the loop testing will no longer be necessary).

  • if you have something like this:

    -check if tween runing

    - then for each .. bla bla

    it will not run the foreach loop if tween is not running.

    if you have:

    • for each ... bla bla

    - if tween is running... then bla bla

    then foreach will run every time, and you will check if tween is running multiple times.

    i can provide more info if you show some kind of code / capx

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Also, you can put your loops inside groups and enable/disable them when needed.

  • Also, you can put your loops inside groups and enable/disable them when needed.

    Groups or Boo

  • I'm actually wondering this, too (I still don't think this has been answered properly). I end up doing for each checks on things all the time and I certainly notice my CPU go up, but I'm never sure if that's really the cause.

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