Group Objects

Get help using Construct 2

Post » Mon Oct 24, 2011 1:17 am

I want to select three different objects and perform the three of them the same event.

How can I group all selected object just to create on event for all of them?
B
12
S
2
G
2
Posts: 28
Reputation: 1,695

Post » Mon Oct 24, 2011 1:27 am

same like before, Add Event -> System -> ForEach -> Choose Object to create an event for all of them.
B
15
S
3
G
5
Posts: 396
Reputation: 4,977

Post » Mon Oct 24, 2011 1:30 am

Three completely different objects rather than three instances of one object?

What xeed said will work for the latter, but for the former you'll have to wait for a new feature called "families" that's going to be implemented soon. That'll allow you to group a bunch of objects under one label and affect all of them at the same time.
B
20
S
9
G
6
Posts: 607
Reputation: 6,112

Post » Mon Oct 24, 2011 1:36 am

sorry didnt read "different". so you are right, i am waiting for families (classes) feature too.
B
15
S
3
G
5
Posts: 396
Reputation: 4,977

Post » Fri Dec 30, 2011 12:46 am

im waiting too for 'families' :)
B
93
S
19
G
34
Posts: 1,840
Reputation: 27,963

Post » Fri Dec 30, 2011 2:02 am

I was thinking a (somewhat difficult) way would be to create one Sprite to represent all objects (that will need to be selected together), but put different "objects images" as different animation in the same sprite. When objects are placed at start of level or whatever, you tell each placed sprite what animation (or object) it is, then set each variable for that object depending on what it is.

Then later when you need to select the multiple objects, you select the single sprite (which is acting like a family here) with extra condition to see which animation (object) it is...

Of course if the animations are the core of the sprite, you may loose something here :)

Does that make sense, or would that work?   I used that type of method on Classic one time and it worked great...   
B
192
S
6
G
7
Posts: 213
Reputation: 10,178

Post » Fri Dec 30, 2011 5:44 am

I know what you mean. The problem then would be that you want your objects to have different variables, health, damage etc... but still share that same base behaviour.

The code you would need to make up for that might take up the same time and space as just coding many objects from scratch.

Ive spent so many hours copying, pasting, editing to get around families but at the end of the day my code was so long that it was eating too much of the available space for the game.

(10mb) if you hope to put it into the chrome store :(
ImageImage
B
73
S
16
G
6
Posts: 1,038
Reputation: 10,473

Post » Fri Dec 30, 2011 2:37 pm

Zetar is right, using one object is the way to go. If they are really that different (different variables, different behavior) it's weird that you would want to do the same thing with all of them. But still, you just have to put all these variable in this object (hp and damages could be the same variables it often represent something similar)
if they share different behavior you often can deactivate behavior on a per object basis.
So yeah, you then just need something like For instance
[code]Mouse: On Left click
   -> Object: set X to 100[/code]
And all of you objects will move in position

If you want one object to do something on this object can do
[code]Object: animation frame = 2
   -> Object: deactivate Bullet behavior
   -> Object: Activate 8 dir behavior[/code]
Only the object with the proper animation frame will move[/code]

If you use animation frames, you won't be able to have specific animation per object. But it can be overcome, if you use different animation instead of different animation frame, you will then compare the animation name.
It will always be easier than copy pasting.
It's what I use when I want to emulate families
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Fri Dec 30, 2011 3:18 pm

You say is much better than I, Yann I created a sort of Life simulator with multiple creatures as one sprite in Classic. (Attackers, grazers, ect...) I just added the extra lines of variables for all creatures, which weren't used in some creatures. I was able to get around the animations. (I never finished that project though It is nice to have instance IDs now!!!!

B
192
S
6
G
7
Posts: 213
Reputation: 10,178


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 28 guests