Handling Multiple Objects

Get help using Construct 2

Post » Mon Mar 19, 2012 2:47 pm

I'm pretty impressed with Construct2 so far and the amount I've been able to do in a short amount of time. Here's something I'm struggling with on my first game, however.

Is there a way to apply a condition to multiple objects? For example, if any item with the drag behavior is dragged, make it 50% transparent?
B
19
S
2
Posts: 37
Reputation: 1,464

Post » Mon Mar 19, 2012 2:49 pm

You can stick them all in a single family, then apply the condition checks to that family.

Drag Item #1 is in Family "Drag"
Drag Item #2 is in Family "Drag"

if Family "Drag" is being dragged, set opacity to 50%

Something like that.
B
56
S
20
G
7
Posts: 305
Reputation: 8,754

Post » Mon Mar 19, 2012 2:51 pm

[QUOTE=TL22] You can stick them all in a single family[/QUOTE]

If you have a license, that is.

If not, you could use a global variable that is changed when you drag an object. And then set opacity to 50 when the variable is 1,
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Mon Mar 19, 2012 3:16 pm

@TL22 Great to know! I haven't bought a license yet, I was trying to see how far I could go without it. I'm pretty sure I'm going to make the leap. Is there any documentation on how the family system works?

@Nimtrix If I do it that way, I'll still have to duplicate the settings for every object right?
B
19
S
2
Posts: 37
Reputation: 1,464

Post » Mon Mar 19, 2012 3:42 pm

Shouldn't have to, have a look at this:

Dropbox: Drag Drop Example
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Mon Mar 19, 2012 3:51 pm

quick and simple :))
B
50
S
12
G
7
Posts: 259
Reputation: 10,371

Post » Mon Mar 19, 2012 4:17 pm

What if I want to drag both an orange and an apple. If I'm dragging the orange, won't the apple turn transparent too if I do it this way?

In other words, how do I say "Whatever current item is dragged, make it 50% transparent"?
B
19
S
2
Posts: 37
Reputation: 1,464

Post » Mon Mar 19, 2012 4:39 pm

If you want all the apples to turn transparent when you lift one apple, and all the oranges to turn transparent when you lift one orange, you probably have to make events and variables for each type of object. Like this

If you just want the single apple/orange to turn transparent, you don't even need variables, but I'm guessing that's not what you're after.
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Mon Mar 19, 2012 4:45 pm

The second case sounds more like what I'm trying to do.

I'll have apples, oranges, dominoes, books, knives. The item being dragged needs to have several properties (transparency is the example).

What I'm trying to figure out is how to not have to program 25 different items differently when they'll behave the same. They'll have different sprites and physics properties.

Sorry if I'm not explaining this well. I looked at the Families example that comes with C2. It sounds like that might really be what I need if I want to be efficient
B
19
S
2
Posts: 37
Reputation: 1,464

Post » Mon Mar 19, 2012 4:49 pm

[QUOTE=sketchee]I looked at the Families example that comes with C2. It sounds like that might really be what I need if I want to be efficient[/QUOTE]

Ah, i see. You're quite right, you'll need families to do that efficiently. Gonna have to buy I guess.
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Next

Return to How do I....?

Who is online

Users browsing this forum: HugeCube, imnotspecial, tomi71, totoe and 20 guests