playMaker

Author Topic: Array List Get Next / Previous[SOLVED]  (Read 3653 times)

LogLady

  • Full Member
  • ***
  • Posts: 150
Array List Get Next / Previous[SOLVED]
« on: May 15, 2014, 08:49:36 PM »
Hello!

I'm trying to make a player select screen using one parent with 5 children. I have one button to move next and one to move back in the array list but it's not working as I expect. The issues are:

1- the first child in the list only appears after I click to go next or previous (it is starting with none selected). I'd like to start showing the first child in list;

2- If I'm moving next and then press to move to the previous item on list it goes to the last object and if I move next again, it goes to the last child shown. I'd like it to go "-1" in the list when moving next and "+1" when moving to the previous. The way it is, looks like there are two arrays being acessed by each button. To make it more clear: If it's in position two on the list and I press "previous" it is not going to position one. It's going to position five and if I press "previous" again it goes to position four. If I press "next" it goes to position three, not to position five.

I made a scene showing the issue Keep in mind that it requires the ArrayMaker to work properly.

Thanks in advance!
« Last Edit: May 27, 2014, 07:18:43 AM by jeanfabre »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Array List Get Next / Previous
« Reply #1 on: May 26, 2014, 04:40:48 AM »
Hi,

 These "GetNext" and "GetPrevious" are not really meant to be used this way. I can see why you are getting confused on this actually.

These actions are meant to be used to "loop" through to apply logic to each elements, not really to "navigate" at will.

To do this, maintain a int variable acting as the "index", then increment that index up and down as you want to get the next or previous item and simply use "ArrayList Get" action.

I don't think I can morph the existing next and previous actions to suit this need, but I'll do a new action for this, specifically for this purpose of navigating.

I have attached this action, let me know if it works for you, and I'll put it in the official package.


the trick is to have a int variable called "based Index", that you inject in the "base index" property of this action as well as in the "Result Index", so that "based index" remains your reference of the current item, and then incrementing for example by 1 will get the next item in that array, everytime you will come back to this state. You can increment negative values as well.

Bye,

 Jean



 

LogLady

  • Full Member
  • ***
  • Posts: 150
Re: Array List Get Next / Previous
« Reply #2 on: May 26, 2014, 11:16:34 AM »
Hi, Jean!

I figured it on saturday how to use the Array List Get and an index to run through the list. I was using 6 events (image attached) to cycle. Now this custom action saves a lot of time and effort. Please, include it on an official update as soon as possible.

Thanks for your support!