How do I make a fridge that can be opened and closed

0 favourites
  • 6 posts
  • Hi. I want to make a fridge, that is by default closed, but when you click on it (with the mouse object) it opens, and if you click on it again, it closes.

    So what I did was:

    1-Added the "mouse object".

    2-Added a sprite ("Fridge") and made 2 animations, both with only 1 frame: One when it is opened and one when it is closed.

    3-Added the following events:

    + Mouse: On Left button Clicked on Fridge

    + Fridge: Is animation "Closed" playing

    -> Fridge: Set animation to "Opened" (play from beginning)

    + Mouse: On Left button Clicked on Fridge

    + Fridge: Is animation "Opened" playing

    -> Fridge: Set animation to "Closed" (play from beginning)

    But when I click on it, nothing happens. It just continues to show the default (closed) animation.

    Can anyone help me and tell me why it's not working?

    (For moderator: Sorry, I meant to post it to Construct 3 help, not Construct 2)

  • It's probably because both your mouse on click events are triggered, and the fridge opens and immediately closes. Change them to this:

    Mouse: On Left button Clicked on Fridge
    
     Fridge: Is animation "Closed" playing -> Fridge: Set animation to "Opened" 
     
     Else -> Fridge: Set animation to "Closed" 
  • I made with Construct 2, hope it could help you :)

    drive.google.com/open

    Cheers

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you soo much! I struggled with it for around 1 hour. I also tried to use the "else" statement but I didn't use a sub-event for it, therefore wasn't able to place it there due to the mouse object.

  • Hi Doggo, are you building a point and click game?

  • Hi Doggo, are you building a point and click game?

    I was building an RPG game, and the character could get some food or spells from a fridge, only when it was open.

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