How do I overwrite click with layers

Get help using Construct 2

Post » Sat May 10, 2014 12:16 pm

hi,
I have a level select level, where there are locks on the top layer and numbers on the bottom layer.
I have set 'on touch of 2 > go to level 2' and this works, but you can click it when the lock is over it.
I want the lock layer to be in front of the numbers layer and to not allow the click (the lock layer is over the numbers layer)
I hope that makes sense.
I have set the 'locks' to solid but the click is still recognised.

Thanks guys.
Will.
B
9
S
1
Posts: 40
Reputation: 1,120

Post » Sat May 10, 2014 1:56 pm

Create an instance Boolean Variable (Lock) and check if the level is locked or not in order to be able to click it.
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379

Post » Sat May 10, 2014 7:09 pm

Thanks but I get stuck at the checking part!
I did a tutorial on level unlocks so I don't really know what some of my code does.
There must be an easy way?
B
9
S
1
Posts: 40
Reputation: 1,120

Post » Sat May 10, 2014 7:22 pm

Try something like:

You need to create a dual condition or 2 conditions in the condition.
You can use a global variable with number value likeCurrent Level

On Touch > "Image Level 3"
System > Current level (is equal to or greater than ) 3 > System go to layout 3
Image
B
75
S
23
G
3
Posts: 673
Reputation: 9,283

Post » Sat May 10, 2014 7:38 pm

OK, thanks, I get that. Let me try.

Cheers.
Will.
B
9
S
1
Posts: 40
Reputation: 1,120

Post » Sat May 10, 2014 9:00 pm

Damn, it's harder than I thought. I am sure that there is an optimal way, perhaps with loops and/or arrays, but that's beyond my scope of knowledge!

Here is a semi-working example, the problem is that when you come back to the main menu, the locking/unlocking resets. That's because the booleans doesn't keep their state after you leave the menu layout. You have to find a way to store each level's condition within a global variable (or an array, dictionary, whatever stores data). I am too confused to think about it right now. Try to improve upon this, if it helps you, and meanwhile perhaps someone else will think something more appropriate!
You do not have the required permissions to view the files attached to this post.
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379

Post » Sat May 10, 2014 10:33 pm

Hi will108 & eli0s, this is how I would do it. I changed a few things around to simplify it. I commented with a ***changed*** or ***new*** in the comment field where I altered things.

I also added in that you have to unlock the levels in order. This can be changed if you want to be able to unlock levels that don't follow order.

If you have any questions let me know.

*Edit: It's implemented similar to how TheDom described it.
You do not have the required permissions to view the files attached to this post.
"In truth we live, In Truth we die"
B
11
S
3
G
4
Posts: 22
Reputation: 3,177

Post » Sun May 11, 2014 2:10 am

@Xerullian That's brilliant :) Indeed, TheDom suggested it in his post, but as I see now how the logic translates to events, I would have never made it by my own. Thanks for sharing :)
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379

Post » Sun May 11, 2014 7:52 pm

Nice job @Xerullian.

@eli0s , I'll always expand on answer if you need it. just ask. Just so you know, that while you technically can't declare a Boolean value with a global variable with C2 in the same way you can with an instance variable. The alternative to to simply use 0 for false and 1 for true as follows.

Here's an example of how I use numbers to represent TRUE and FALSE

Image
Image
B
75
S
23
G
3
Posts: 673
Reputation: 9,283

Post » Sun May 11, 2014 8:20 pm

@TheDom thank you very much for your input and for offering help in the future. I really appreciate it :)
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 12 guests