How do I set layer invisble ?

0 favourites
  • 10 posts
From the Asset Store
A whole set you need to create a gorgeous winter 2d game
  • I came across a strange behaviour here. In this little code where everything looks fine, clicking the green button doesn't switch layer 0 where Red square is, as it should. Button is active because because it triggers correctly Flash behaviour.

    Did I miss something ??

    https://www.dropbox.com/s/nf1lm16l1e5w3ah/SetLayerInvisible.c3p?dl=0

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • This is a common mistake. Don't separate your logic. Use one on-tap event, and then use a sub-event to check Layer is visible ELSE do the other action.

  • Quick Fix:

    If you set the System Wait to 0.1 Seconds this should work. With no time between the first event will run and set the layer invisible then the second will run and reset the layer visible.

    Correct Way:

    Else statement or a counter to verify which layer

    Check out this tutorial:

    youtu.be/GFTS7efp_Cg

  • Thnaks both of you, and thanks winstreak for taking the time for the clear video !

    I understand what's going on here. By the way, exemple here was not very well chosen because my real problem doesn't involve the possibility to use the Else statement.

    I can't post the all code but here is the segment that poses problems :

    In here, everything works well when the highlighted line is not present (wait 1 sec) : Layer 2 is shown on screen (Red button and Fight text are on this layer) and when button is clicked, layer 2 is set to invisible and State is changed to its correct value.

    But when action "System > wait 1 sec" is added, everything works the same but "system > set layer 2 invisible" is not triggered.

    What happens here ??? I really don't get it.

  • I believe this is what is happening.

    Your first 2 requirements get met state and isMoving and then you tell the system to wait 1 second. After 1 second did you touch the button as well as overlap an enemy as well as hex overlap player.

    So you are asking for the first 2 checks to meet the next 3 checks at 'exactly' 1 second later or else it fails

    Might be incorrect, but thats my hunch from the small bit of code I see

  • Your first 2 requirements get met state and isMoving and then you tell the system to wait 1 second. After 1 second did you touch the button as well as overlap an enemy as well as hex overlap player.

    Yes, every conditions are ok.

    The thing is that after "Touch button", every event occur (meaning Pick and Overlapping are also met) : Destroy enemy & Set occupied to 1. Only Set layer 2 invisible doesn't work.

  • Triggers should always be placed as a top-event, as they run outside the usual loop. The Wait will not affect the "On tap" event.

    A better mechanism is to put the On tap code in a Group, disabled by default. Then when your attack mode is triggered, run the Wait code, adding "Group enable", at the end to turn on the input tracking.

    Disable the group again, when appropriate.

  • Hello,

    I tried your approach with the onTap code in a group being enabled when necessary. And it is still the same.

    I dont't understand why every action is working (destroy, variable changes value) but only layer visibility is not. Is there something special with this action that causes this ??

  • We can't see your parent event, so the question is; is the attack code being called only once, or repeatedly, which would keep making the layer visible.

    You may need an "attacking" state, so you don't keep repeating the attack state.

  • You're a genius !!!!

    I added a Trigger once condition and everything is fine now !

    Thank you !!

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