How do I make a character screen

0 favourites
  • 8 posts
From the Asset Store
40 short musical loops, perfect for playing in the background on different screens.
  • Hi. I want to make a character window to pop up when player presses C.

    So far so good:

    On keyboard C pressed -> create object Character_Window on layer HUD ...

    How do I make the window disappear when i click C again though? I tried different ways but cant figure out still. Maybe with instance variables? I thought this is a simple thing to do, so please explain me

  • Use a variable - CharacterWindowVariable

    On keyboard C pressed       | Create CharacterWindow
    CharacterWindowVariable = 0 | Set CharacterWindowVariable = 1-CharacterWindowVariable
    
    On keyboard C pressed       | Destroy CharacterWindow
    CharacterWindowVariable = 1 | Set CharacterWindowVariable = 1-CharacterWindowVariable
    
    [/code:3llldr76]
  • oosyrag

    Thank you for your help.

    Sadly it's not working. I think it is still creating and destroying the window at the same time and therefore nothing happens. If I put a wait - 0.1 seconds before changing the variable - the window apears, but i can't close it....

    Any ideas?

  • UPDATE: I put wait 0.1 seconds after destroying the object and it finally works

  • Whoops yes I made another very common beginner mistake. Actually I recommend not using wait - it is the cause of a lot of headaches. Add ELSE to the second event.

    I forgot about that. If you use else, you might not need a variable at all.

    On C pressed, if CharacterWindow does not exist - Create CharacterWindow

    ELSE On C pressed - Destroy CharacterWindow

  • Whoops yes I made another very common beginner mistake. Actually I recommend not using wait - it is the cause of a lot of headaches. Add ELSE to the second event.

    I forgot about that. If you use else, you might not need a variable at all.

    On C pressed, if CharacterWindow does not exist - Create CharacterWindow

    ELSE On C pressed - Destroy CharacterWindow

    Can't add "Else". Probably because I have the condition of pressing C which cannot have "else". Any ideas?

  • Else has to be the top condition in the event

    EDIT: Ok so you can't use else after a trigger.

    The workaround is to make a sub event after pressing c, check if window open, then the next event after that is else.

    On C Pressed
    |
    +- Check if Window exists - Make Window
    +- ELSE - Destroy Window
    [/code:1bkdn8fk]
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yep, it works:

    On C pressed

    • System compare two values: CharacterWindow.count < 1 --> create CharacterWindow
    • Else destroy Character Window

    Thanks for your help

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