Reading values from an array vs manually entering the value?

  • Hello,

    I was wondering if it was performance intensive to continuously read values from an array?

    I have a lot of functions that sets a sprite's position, angle, opacity to different values for different if conditions. This fills up the even sheets with a lot of actions.

    I was wondering why not I just save the position angle opacity values in an array, and call another function to read the values from the array and set it into the function that changes the sprite's various attributes.

    Would this method be slower than just directly setting the values and would it be a burden on performance?

    thanks

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It's hard to tell, but you can run a test:

    On every tick

    Repeat 10000 times -> Function Call "MyFunction"

    In the function try setting the values directly or from the array.

    Run the project in debug mode and compare the performance.

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