Create Object with Families, how to control it?

Get help using Construct 2

Post » Sat Jun 16, 2012 5:40 pm

Hello Everyone,

I am testing the families, however I find something that I cannot resolve.

I have a family with two objects inside Sprite1 & Sprite2.
Then in my layout I added a button.

In the event Sheet, I have.

Button on Clicked: Create Object FamilyName   (with layer & position).

Then I figured, that I cannot control wich object of the family will appear, for what I see is random.

Is there a way to control this?

I mean for example if I have two buttons, and the button1 is pressed create the sprite1 of the family.
If the button2 is pressed create the sprite 2 of the family.

I was thinking in a variable, but since I cannot give any value to the create object I discard that Idea.

So any advice, recommendation ?

Thanks in advance.
Best Regards.
Image
Image
B
26
S
2
G
1
Posts: 71
Reputation: 2,662

Post » Sat Jun 16, 2012 6:21 pm

Instead of choosing the family in the 'Create object' action, just choose either Sprite1 or Sprite2.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,630

Post » Sat Jun 16, 2012 7:08 pm

Yeah I know that can be one solution, but the point is that I'm thinking how to do a fighting game.

Layout 1: Character Selection.
Click on a sprite which represent the character and load the follow layout.

Layout 2: Gameplay
This is the problem.
Because if I have an sprite for every character (each one have its own animations) I will have like 40 repeated events, this is why I am trying to figure how to use it family.

A more easy explanation of what I want to do (or trying to do):
- In layout1 I have a variable "characterselected" which is number.
So, in the next layout I would like to do something like:
If characterselected=1 Load on layout the Sprite1
If characterselected=2 Load on layout the Sprite2

So, basically I am wondering if there is a way to this, without to repeat like 80 events...

I was searching and it seems no one has made a fighting game :(
Image
Image
B
26
S
2
G
1
Posts: 71
Reputation: 2,662

Post » Sat Jun 16, 2012 9:30 pm

you will have to make a create action for every character you choose,

so if characterselected=1 > create sprite 1
and so on...

once you have all that, because all sprites are in the family,
they will inherit all other action and events that are on the family where they are in.

like changing animation, you change animation of the family
like collision , check for collision on the family



ImageImage
B
61
S
19
G
6
Posts: 809
Reputation: 9,028

Post » Sun Jun 30, 2013 7:14 pm

Unfortunaly this hasn't been implemented in C2 I had the same problem too. Let's hope someday they listen us and let us decide what will be spawned inside the family on creation like it was possible in C1.
B
30
S
6
G
5
Posts: 433
Reputation: 6,061

Post » Mon Jul 01, 2013 12:06 am

@Guif0DA what do you mean? have objects on runtime added to the family?
not aware of anything that was in c1 and not in c2 dealing with familiesvtrix2013-07-01 00:07:54
ImageImage
B
61
S
19
G
6
Posts: 809
Reputation: 9,028

Post » Mon Jul 01, 2013 11:31 pm

[QUOTE=vtrix] @Guif0DA what do you mean? have objects on runtime added to the family?
not aware of anything that was in c1 and not in c2 dealing with families[/QUOTE]
I mean the problem from the first post in the topic, the random creation of sprites inside family if u select to create the family. in C1 it was possible to control that so you could select exactly the object from a family u would want to by selecting create family.
B
30
S
6
G
5
Posts: 433
Reputation: 6,061

Post » Thu Nov 21, 2013 6:11 pm

I need this too.
No fix yet?
I think an extra field when selecting a family populated with the objects contained in that family, or an option to randomise them would be great.

Thanks.
B
11
S
2
Posts: 9
Reputation: 1,502

Post » Mon Feb 24, 2014 2:49 pm

Ashley wrote:Instead of choosing the family in the 'Create object' action, just choose either Sprite1 or Sprite2.



Help Ashley
would have to have a new "create object", it would be used to create familys (uid or "string" or index);

example: "create object" Family1 (index)
B
32
S
7
G
1
Posts: 14
Reputation: 4,354

Post » Tue Feb 25, 2014 1:56 pm

I think that you could create your character in other way. For example you could create or use (there is a nice plugin for this purpose in the scirra forums) a plugin to create objects from a family it some degree of dynamism.

Lets suppose this:

- ryu and ken belong to fighter family
- player 1 chooses ryu and player 2 chooses ken
- then you store the names of the charaters (ryu and ken) in some dictionary where the player 1 is key 1 and player 2 key 2 and the names stored are those of the characters
- then you take both keys and its respective values and use (sorry I cant paste url but look for [Plugin] Nickname, [Behavior] Nickname in google with Construct 2 appended and you should find it) plugin to create your desired sprite accordingly, note that you will still have all the functionality for both sprites as defined in your family

Hope it helps not quite sure since I might have not understood your purpose. :P
B
10
S
3
Posts: 75
Reputation: 864

Next

Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 20 guests