Open/Close door animation

Get help using Construct 2

Post » Thu Mar 28, 2013 4:55 pm

     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!
B
6
S
1
Posts: 31
Reputation: 703

Post » Thu Mar 28, 2013 11:40 pm

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)
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Sat Mar 30, 2013 4:52 am

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: http://doobiedoctor5000.allalla.com/burgerBonanza/buffetBonanza.capx

Oh yeah as for why I'm so late in posting it, I was internet-free last night.DoobieDoctor50002013-03-30 05:09:32
B
6
S
1
Posts: 31
Reputation: 703

Post » Sat Mar 30, 2013 3:32 pm

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)
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Sun Mar 31, 2013 5:36 am

[QUOTE=Nimtrix] 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[/QUOTE]

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.
B
6
S
1
Posts: 31
Reputation: 703

Post » Sun Mar 31, 2013 3:23 pm

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.
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Sun Mar 31, 2013 7:07 pm

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.DoobieDoctor50002013-03-31 19:11:59
B
6
S
1
Posts: 31
Reputation: 703


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, Google [Bot], Magistross, mallorcaredes, zatyka and 28 guests