How do I cycle through an Array?

Not favoritedFavorited Favorited 0 favourites
  • 8 posts
From the Asset Store
Perfect for your zombie game! Animated from motion capture data Left, Right, Top Down!
  • I am not sure if this makes sense, but I was trying to make a visual novel like text display. I am trying to make it so every time I left click it moves what cell is being displayed as text down in order.

  • Set up an Array and put each line of dialogue into a separate cell in order. Then make a variable called DialogueIndex starting at 0. Set your Text object to show the array value at that index. After that, make an event for left mouse click that adds 1 to DialogueIndex and then updates the Text object to the next array cell, so each click just moves the text down the list like a visual novel.

    Hope this is what your looking for and helps!

  • I mean, I understand the idea of how to do it. I just don't know how to execute it in the engine.

  • I just don't know how to execute it in the engine.

    Exactly as described in the comment above.

    There are also two official examples, search for "visual novel" in the example browser. One uses an array, another - flowcharts.

  • > I just don't know how to execute it in the engine.

    Exactly as described in the comment above.

    There are also two official examples, search for "visual novel" in the example browser. One uses an array, another - flowcharts.

    I tried to look at the examples before and couldn't understand how they did anything in either one. The tutorial for arrays and such doesn't really explain it very well, like what does push or back or cur actually mean or how they work or how they work together in events. From the start I wanted to know how do I set an event loop so that everytime I press click it can cycle through the array. So far I don't have the answer.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You don't need to know how to use all the features of an array to use them. All arrays do is store multiple values in them, and all you need to be able to do is set the size, set values, and get values.

    Arrays indexes are 0 based, which means to access the first element of an array the expression would be Array.At(0), and the second would be Array.At(1), and so on...

    If you ever try to set a value in a cell that doesn't exist it will do nothing, and if you try to get a value from a cell that doesn't exist you'll get 0.

    And as noted above a way you can do what you're asking in your OP will look like this:

    So just literally changing a number variable to access different cells.

    The push action just increases the size of the array by 1 and places a value in the new cell. Array.CurValue, CurX, etc... are used when you use the "for each element" condition. You really don't really need to use those things. You could use normal event loops with loopindex as well. Overall arrays tend to be more closely related to traditional programming and is more abstract sometimes to understand them.

  • You don't need to know how to use all the features of an array to use them. All arrays do is store multiple values in them, and all you need to be able to do is set the size, set values, and get values.

    Arrays indexes are 0 based, which means to access the first element of an array the expression would be Array.At(0), and the second would be Array.At(1), and so on...

    If you ever try to set a value in a cell that doesn't exist it will do nothing, and if you try to get a value from a cell that doesn't exist you'll get 0.

    And as noted above a way you can do what you're asking in your OP will look like this:

    So just literally changing a number variable to access different cells.

    The push action just increases the size of the array by 1 and places a value in the new cell. Array.CurValue, CurX, etc... are used when you use the "for each element" condition. You really don't really need to use those things. You could use normal event loops with loopindex as well. Overall arrays tend to be more closely related to traditional programming and is more abstract sometimes to understand them.

    It's still not working. Like always I can get it to display the first cell but afterwards it still only displays "0"

  • You don't need to know how to use all the features of an array to use them. All arrays do is store multiple values in them, and all you need to be able to do is set the size, set values, and get values.

    Arrays indexes are 0 based, which means to access the first element of an array the expression would be Array.At(0), and the second would be Array.At(1), and so on...

    If you ever try to set a value in a cell that doesn't exist it will do nothing, and if you try to get a value from a cell that doesn't exist you'll get 0.

    And as noted above a way you can do what you're asking in your OP will look like this:

    So just literally changing a number variable to access different cells.

    The push action just increases the size of the array by 1 and places a value in the new cell. Array.CurValue, CurX, etc... are used when you use the "for each element" condition. You really don't really need to use those things. You could use normal event loops with loopindex as well. Overall arrays tend to be more closely related to traditional programming and is more abstract sometimes to understand them.

    Figuered it out. If you do it that way it adds one to "X", so to make it go down, you do it as Array.At(0,index)

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