How can I make this work (instance variable) ?

0 favourites
  • 11 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Hey. I am trying to change the portals from active to inactive. I am verifying this for "PortalEnterBox2" by pressing the "P" key but it doesn't work. What is happening is this:

    If I set the instance variable "portalOn" to false to be the default on start of layout, if I press "P" it changes the state of the portal to active but when I press again "P" nothing happens.

    If I set the instance variable "portalOn" to true to be the default on start of layout, if I press "P" nothing happens.

    Please, look at the screenshot and tell me what I'm doing wrong. Thanks.

    Link here https://www.dropbox.com/s/hua8wwgcdg0j1 ... m.jpg?dl=0

  • Don't check a condition then check for the inverse. Use 'Else'. The problem is you set it to one state, then immediately set it to the opposite state. 86/87 turn it off, then 88/89 checks if it is off, and turns it on again.

  • Thank you ! I've done what you told me and it works.

  • Hi I need your help again <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile"> , please.

    The problem I have is where "state = 1" . I have several portals. What I am trying to do is when MovableObjects_Fam is overlapping PortalEnterBox_Button (nr=1), PortalEnterBox1 will activate, and it works. But for some reason PortalEnterBox_Button is not changing from frame 1 to 0 or vice versa.

    If I have 2 or 3 portals and buttons in the scene only one of the buttons will change his frame.

    Screenshot: https://www.dropbox.com/s/2byd7wo9fvhj7 ... 2.jpg?dl=0

  • I can't really see the issue from the screen shot. You'd have to post a CAPX.

  • I don't want to share the .capx , it's a big project I am working on for some time now... I will try other ways, thanks.

  • anty21ro

    If you want people to help you, extract only the events you show in the screenshots, and make a simple capx file with replaced images. Its easier when we have control over the capx project, instead of guessing whats wrong by looking.

    I am also working on a portal game, but I havent started making code, just art assets for now.

  • Hei. I've made an example .capx. There are 3 portals. When Player touches the button it should turn from red to green (same for the portal that is related with), but it does only for one of the 3 portals.

    https://www.dropbox.com/s/a6qv3uzabgf2t ... .capx?dl=0

  • The problem is you only pick the corresponding PortalButton with the overlap condition. The Else defaults to ALL PortalButtons.

    Also, there is no reason to duplicate the code three times. This can be simplified by giving both objects the same ID, which you do already for PortalButton (nr), and then the one can pick the other when necessary.

  • Thanks a lot blackhornet.

    Does the "Browser Log in console: "NR=" " influences the picking in any way ?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • No, that was just debugging.

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