How do I Create Frame Independent Functions

0 favourites
  • 3 posts
From the Asset Store
Selection frame like in RTS games, works both on mobile and desktop devices.
  • I have a function that runs and goes through hundreds of sprites ... every time that happens the game freezes for few seconds, the results dont need to effect the objects immediately every frame.

    How do i make this frame independent ?

  • A function, like a loop will be executed on a single tick.

    Do you need your loop to go through all the elements.

    If for example you are looping through each instances of an object type and want to do a specific action on a specific instance, once you found it, use the stop loop action, it will prevent from looping through the rest of instances which we know are wrong/not the one you are looking for and can allow you to freeze your application less.

    If you want to not freeze the execution, yet still, each tick analyse through a bunch of the instances (but enough that you don't feel the freeze), it depends in great part on your project's code, but you could increment the value of a global variable each tick, and use this value to pick an instance (through its IID possibly ?) and analyse only this instance through a specific event.

    Still a "loop", but which execution goes over several frames of execution.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I see, so only way of doing this is still in one frame but you instead divide the entire process into several frames, ... there is a point in my game when the number of instances can be even up to few thousands.

    I guess i set a global variable that will designate how many of the objects i will go through each frame with IIDs and each frame i will check for my conditions. And depending on the CPU load i can have an other function that will check the variable to dial down the number of IIDs checked / frame ...

    That would in essence create the frame independence ... Thank you

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