How do I Rotate through Array values based on timers?

0 favourites
  • 8 posts
From the Asset Store
Simple resize and rotate events for any sprite, quick and easy event sheet that you can use for your own projects.
  • I have a simple premise, you see every 30 seconds (a date keeper) I want a text value to change to the next array value I've placed on the x axis. Now, I have a faint clue as to the use of Curvalue but my attempts have ended in failure. If someone can let me know how to do this I would be grateful.

    Note: I've read the Array tutorials and know about appending values and such but not how to cycle through the NEXT value. As in there isn't a "do next value". Unsure how I would even loop them.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You could use the Array.At(x) expression, where x is the index you'd like to get the value for and 'Array' is the name of your Array.

    Assuming you have a global variable called "CurrentIndex", you could do something like this:

    Every 30 seconds:

    -- Set text to Array.At(CurrentIndex)

    -- Add 1 to CurrentIndex

  • You could use the Array.At(x) expression, where x is the index you'd like to get the value for and 'Array' is the name of your Array.

    Assuming you have a global variable called "CurrentIndex", you could do something like this:

    Every 30 seconds:

    -- Set text to Array.At(CurrentIndex)

    -- Add 1 to CurrentIndex

    Thats almost exactly what I had tried.. but perhaps I forgot to assign the value as an array.

    EDIT: I'll let you all know how it turns out and post a capx.

  • Rotate Array With Push and Pop

    Run it, then UP and DOWN arrow keys to "rotate" the array.

    Using this method you can just get the value of a fixed index like..

    DateKeeper = Array.At( 3 )

    Using Pop and Push, the value at (3) will be different.

    Hope that helps!

  • Ahhh seems I might've misunderstood what you wanted. Although my method still works, it might be a bit of overkill...

  • Alright everyone, I hope this helps you all:I am hoping someone knows of maybe a better way to do something like this, but this is the 'proof of concept' as it were. It needs more polish. Right now its set to a 1.0 second cycle. Which should be made longer for more use but is convenient for testing purposes.

    EDIT:

    [s/g8g8ictk18lloau/time_runner.capx?dl=0]

  • You code does not look very much to the point and your times will produce slight inaccuracies (since it sets timervariable to 0 instead of timervariable - 1 (the time of your cycle))

    https://copy.com/q46Og7yBAVnJkZWu

  • Yes I agree there is a time delay so its not going to be exactly 1 second each time.

    EDIT: Well I checked yours out and although I cant understand it I think its way more efficient and it taught me that you can list Values in one variable? GlobalVar: Stuff1;Stuff2;Stuff3;

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