How do I create a list that is NOT a pull down?

Get help using Construct 2

Post » Wed Sep 09, 2015 8:30 pm

Hi to All,

My question:
How do I create a list for mobile devices? Similar to the standard listview in jquerymobile or the tableview in Xcode?

Thanks in advance for your help.
B
6
S
1
Posts: 21
Reputation: 822

Post » Tue Oct 06, 2015 5:39 pm

So, I take it from the lack of response to my question, that there is no way to generate a list (similar to what is seen in all cell phones) and no way to populate that list.

Too bad, I was hoping that Construct 2 could create applications as well as games( <ul><li></li></ul>). The list is a standard for all the applications though.

Create a list/tableview and then populate the list using something like json.

Save back to the list using localstorage or the like.

-Just4Fun
B
6
S
1
Posts: 21
Reputation: 822

Post » Tue Oct 06, 2015 5:52 pm

The only built-in thing in Construct that resembles what you want is the "List" object with its type set to "List box".
B
67
S
28
G
24
Posts: 970
Reputation: 18,675

Post » Tue Oct 06, 2015 7:50 pm

you could ofcourse easily create a fully customizable list using the TokenAt expression in combination with the dictionary object..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Oct 06, 2015 8:08 pm

The built in feature is called an Array Object. It lets you do a list on a 1, 2, or 3 dimensional matrix
Use an array for your list. This will let you sort, pop, delete and insert your list entries.

https://www.scirra.com/tutorials/307/ar ... -beginners

It will also let you load and save from a .json string!

In C2 the Array variable is an Object,. You cant set a global array From the event sheet, thanks littlestain!. Nor can you make an array instance variable like in Scripting languages. From the Array you can load the list into a Dictionary for additional functionality.

You can insert an arrays .JSON string, into another arrays index. This makes it possible to save all of your games arrays into a single array. This is a simple method of making a custom save game file. Makes it really easy to load too! Just one string!

I recommend the Array because it is easier to understand for people who have used real scripting languages like C#, Javascript, or Python. You can also find usable code theory on StackOverflow.com. Just substitute the Array object for the Array Variable that they are describing.

You could also do it manually with a Text object, Text instance variable, or a Dictionary object. This will require some Ninja code skills, and the knowledge of the get token at, and Token count, and making your own loop to cycle through the text. The array object has all of this built in! Not to mention the Sorting, popping, inserting and deleting.

Here is the code difference to get the word "Text":

Code: Select all
tokenat("The,Text,From,Your,Custom,Built,String,Here"), 1, ",")


Or just grab the second value of an array (0 base):

Code: Select all
Array.At(1)


Trust me, the second one is MUCH easier to debug when you are scanning over hundreds of events.

You will not have to "Cast" your values into Floats, integer or strings either. You just grab the value and run!
Here is an example of grabbing some screen locations of a game tile from a string, the INT() is me casting them from a string into an Integer:

Code: Select all
X:  int(tokenat(SliderController.Slider_Label_Offset, 0, ","))

Code: Select all
Y:  int(tokenat(SliderController.Slider_Label_Offset, 1, ","))


Here is what the array would look like:

Code: Select all
X:  Array.At(Array.CurX)

Code: Select all
X:  Array.At(Array.CurY)


Anyway, the amount of text in your expression, and casting variable back and fourth takes up valuable CPU resources. You also can NOT do complex expressions in a function like grabbing tokens, you need to have global/instance variables set for the function to be able to access them.
Last edited by jojoe on Tue Oct 06, 2015 9:38 pm, edited 4 times in total.
B
29
S
8
G
4
Posts: 767
Reputation: 5,985

Post » Tue Oct 06, 2015 8:18 pm

jojoe wrote:In C2 the Array variable is an Object,. You cant set a global array, nor can you make an array instance variable like in Scripting languages.


Correct me if I'm wrong..

Isn't an array set to global on creation?
Wouldn't adding an array to a container work as using it as an instance variable?

Maybe you mean something different, that's why I'm asking..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Oct 06, 2015 9:10 pm

LittleStain wrote:
jojoe wrote:In C2 the Array variable is an Object,. You cant set a global array, nor can you make an array instance variable like in Scripting languages.


Correct me if I'm wrong..

Isn't an array set to global on creation?
Wouldn't adding an array to a container work as using it as an instance variable?

Maybe you mean something different, that's why I'm asking..


Ah sorry about that, @LittleStain.

I meant the way you create them. In conventional programming you define the global variables at the top of the script (usually, they dont actually have to be here). This is where most people would assume you make an array.

I mentioned this because they might think C2 does not support them. When they are actually an object that you add to the game board, rather than to the list of Global variables. People who are used to normal programming might overlook this when they right click on the event sheet to make one is why I mentioned it.

I am not very good at English, :) thanks for your patience :)
B
29
S
8
G
4
Posts: 767
Reputation: 5,985

Post » Tue Oct 06, 2015 9:18 pm

Thanks! REALLY appreciate the reply to my question. Sounds doable. Just needs some good skills. I'm not a code jockey. I'll try some things out and beg for help when I'm approaching the deep end of the pool. For me that could be at wading level. ;-)

-Just4Fun
B
6
S
1
Posts: 21
Reputation: 822

Post » Tue Oct 06, 2015 9:31 pm

jojoe wrote:You also can NOT do complex expressions in a function like grabbing tokens, you need to have global/instance variables set for the function to be able to access them.


Could you explain this statement?
Why wouldn't you be able to do this?

Maybe you mean something else with "function" and/or "complex expressions", but I haven't run into this limitation..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Oct 06, 2015 9:39 pm

LittleStain wrote:
jojoe wrote:You also can NOT do complex expressions in a function like grabbing tokens, you need to have global/instance variables set for the function to be able to access them.


Could you explain this statement?
Why wouldn't you be able to do this?

Maybe you mean something else with "function" and/or "complex expressions", but I haven't run into this limitation..


Sorry again, the Function Plugin :p

My English.... I just cant!
B
29
S
8
G
4
Posts: 767
Reputation: 5,985

Next

Return to How do I....?

Who is online

Users browsing this forum: RetrocadeMedia, sebrosen, Yahoo [Bot] and 31 guests