How do I simplify this?

Get help using Construct 2

Post » Fri Dec 12, 2014 10:54 pm

I have a function that needs to iterate over a family to display every member of it in a list. So far the logic looks like this:

Image

Is there some way to simplify this process so I don't have to update it every time I add a member to the family? I'm also having some difficulty with the order. Like I tried to set the blend mode (so they don't appear outside of the scrollbox) but event 39 did not work so I had to iterate over the individual members as well. As an aside, I noticed when I set the height of the sprite these items are pinned to the pins move. This shouldn't be an issue though as I'll just rely on the instance variable.

So how do I make this simpler when my list gets to 30+ members I don't have so much of a headache?
B
10
S
2
G
2
Posts: 73
Reputation: 1,044

Post » Fri Dec 12, 2014 11:12 pm

Perhaps you can remove the actions after the create object actions, and put them in a separate Event, condition: Heroes > On Created...
This way, whenever an object in that family is created, it'll run through just 3 actions(the actions you had after the create object shown in your image).

The heroes family will need to have the instance variables and behaviors applied to the family.

Or create a seperate family if you need other things besides heroes, etc..
B
43
S
19
G
65
Posts: 1,104
Reputation: 37,945

Post » Fri Dec 12, 2014 11:37 pm

Use family
B
97
S
35
G
29
Posts: 3,139
Reputation: 28,371

Post » Sat Dec 13, 2014 12:16 am

Okay so I was able to simplify 2 of the actions by using an event with "Heroes on created" + "Heroes on layer..." event. But I still don't know how to iterate over the family to make sure new members get added to this list if I add new members to the family.
B
10
S
2
G
2
Posts: 73
Reputation: 1,044

Post » Sat Dec 13, 2014 12:30 am

What do you mean? If the members are in the family, then when they're created they will be automatically added to the list.
B
43
S
19
G
65
Posts: 1,104
Reputation: 37,945

Post » Sat Dec 13, 2014 12:55 am

Is what I mean is if I add a new member to the family I will need to go back to event 38 to add a create action and a set instance variable action.

I can't use say... "loop 0 until Heroes.count" create "Heroes". This would create a list of random heroes.
B
10
S
2
G
2
Posts: 73
Reputation: 1,044

Post » Sat Dec 13, 2014 1:16 am

have you tried putting the instance variable action in the oncreate event and changing the object to the family?

Why would you loop until Heroes.count to create heroes? Count is the number of heroes that have already been created. BTW, If you have members of the family in the layout when the layout starts, the on create will automatically get called.
B
43
S
19
G
65
Posts: 1,104
Reputation: 37,945

Post » Sat Dec 13, 2014 7:45 am

Please tell us your requirements, and maybe even provide a full capx. That would make it easer to help.

Also I think you're confusing what Families can do for you. At design time, a Family's members are object types. At run time, a Family can have a number of picked objects (instances) which can consist of any Family members, or none, or one of each, etc. You can't expect a Family to have 1 instance of each member (as it seems you're wanting to do).
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Sat Dec 13, 2014 2:25 pm

My requirements is I need to create a scroll list box that creates and displays a list of options for the player. I'm looking to make a strategy RPG so I'll be needing this a lot. In this particular case I'm displaying a list a classes with the goal of the player selecting one for recruitment. I'll admit it has taken me a week just to assemble this portion of my game and it's gotten very frustrating. Here's the entire CapX file. Most of the relevant functions are in the listbox group. The bottom right button in Layout 1 summons the list.

To do:
* Scale the scrollbar to the size of the listbox.
* Display a tooltip on class mouseover.
* Enable Dragdrop from the listbox.
* Possibly package this as a tutorial or a plugin.
You do not have the required permissions to view the files attached to this post.
B
10
S
2
G
2
Posts: 73
Reputation: 1,044


Return to How do I....?

Who is online

Users browsing this forum: tarek2 and 11 guests