0 Favourites

How do I overwrite click with layers

  • 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.

  • Create an instance Boolean Variable (Lock) and check if the level is locked or not in order to be able to click it.

  • 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?

  • 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

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • OK, thanks, I get that. Let me try.

    Cheers.

    Will.

  • 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!

  • 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.

  • Xerullian That's brilliant

  • 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

  • TheDom thank you very much for your input and for offering help in the future. I really appreciate it

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)