Open/Close door animation

0 favourites
  • 7 posts
From the Asset Store
Random Maze Generator with Door & Key System - tutorial capx
  • I'm having a few issues getting an animation to work properly. I want to achieve the effect of a door opening and closing. At first, I tried doing it with an animation within a single sprite, but given the openDoor sprite needs to be larger than the closedDoor sprite, I decided to instead use completely different sprites.

         I'm using the following events:

    • Mouse ---> On Left Click on closedDoor ---> closedDoor ---> Destroy

         AND                               ---> System ---> Create openDoor 330,413

    • Mouse ---> On Left Click on openDoor ---> openDoor ---> Destroy

         AND                               ---> System ---> Create closedDoor 315,429

    With these events, the closed door will initially destroy and spawn the open door upon clicking on it, but the open door will NOT destroy NOR spawn the closed door upon clicking on it.

    I'm at work right now so I can't upload the capx, but if need be I will upload it tonight after work.

    Thanks you!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It's hard to say what's going on without seeing your .capx or event sheet.

    Anyway, I wanted to try some things with 3D animated sprites, so I made a door example for you while I was at it. All the frames of the animations have been cropped so they are different sizes, so if you look at the image-points in the animation editor you can see how I've moved them around to compensate for the different sizes of the frames.

    Hope it's helpful in some way, if not you should post your .capx:

    OpenDoor.capx (r123.2)

  • I looked at your capx. Wow I don't understand what you did. I feel stupid but the animation works flawlessly. I will study it some more.

    In the meantime, this is my capx: doobiedoctor5000.allalla.com/burgerBonanza/buffetBonanza.capx

    Oh yeah as for why I'm so late in posting it, I was internet-free last night.

  • Both your door frames were the same size, so you can make them frames in one animation without having to move around the image-points like I did in the other example.

    Here's the best and easiest way to do it (in my opinion):

    doobiedoctor_edited.capx (r123.2)

  • Both your door frames were the same size, so you can make them frames in one animation without having to move around the image-points like I did in the other example.

    Here's the best and easiest way to do it (in my opinion):

    https://dl.dropbox.com/u/11087850/doobiedoctor_edited.capx

    Thank you for the example. The reason I originally chose to use two separate sprites is because the door sprites are different sizes. Looking at your edition, the door gets smaller when open. My goal was to prevent that. I'm trying to get it so the height of the door hinge remains constant.

  • I would recommend fixing the problem at it's core instead of trying to scale inside C2. By that I mean making the sprites the right size before you import them, it makes the whole process a lot easier.

    Now, obviously, your solution should also work, I'm just saying this is how I'd prefer to do it.

    This way, if you want to change the animation at some point, all you have to do is make sure the frames are the same size and it should work straight away without having to create new sprite objects and position/scale them.

    I've corrected the last example so that the hinges are the same size, but I've just scaled the sprite up, so expect some loss of image quality.

  • I tried replying last night but I guess the servers were wonky. It kept saying I didn't have permissions to post.

    I thought I had found the solution. Go ahead and re-download my capx file again to see what I did.

    But then I see your next solution here and I'm so jealous! Yours works WAY better than mine. As you can see, with my solution, the door will kind of stick at times unless you move the mouse before each click. YOUR way is what I wanted to do, where every click would activate the door.

    Thanks again for the solution. I will study it and try to see just what you did.

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