Animation Frame changes at Specific Angles

Get help using Construct 2

Post » Thu Jun 06, 2013 10:11 am

Hi all, my first post here. This is really an interesting software! I'm an artist, so computer logic is new to me, but I'll like to learn.

Now, what I'm trying to do:

1. Make a sprite rotate within 320-350 degrees based on arrow keys.

2. Sprite contains multiple frames.

3. By default, only Frame 0 is displayed within the 320-350 degrees.

4. However, when sprite hits certain angles, for example 349 degrees, Frame 1 is displayed instead.

This is what I have so far:


And my .capx file:
https://dl.dropboxusercontent.com/u/7868767/XRay.capx


So what should be a proper way to do the above? With my current way, the sprite switches to Frame 1 right after I start rotating it, and stays at Frame 1 without any more changes.
Thanks for all help in advance!
whazzup2013-06-06 10:17:28
B
4
Posts: 3
Reputation: 231

Post » Thu Jun 06, 2013 10:38 am

Hey !

There are 3 things that you should do if you want this to work :
1/ right click on the 6th event (the one with the 4 angle tests), and make it an "OR" block, because as it is, it will only trigger if all the conditions are verified, witch isn't possible.
2/ You have to have at least 2 animation frames. In the capx you linked, the animation is only in 1 frame !
3/ If you want to manage the animation frames like this, you have to set the animation speed to 0, or it will play the animation. By default (and in your capx), it is set to 5 frames per seconds. So even if you change the frame to 0 (and if you have multiple frames, cf 2/), if will play the animation to its end, and redisplay the 2nd frame in 0.2s.

I had more things to tell on your capX :
- carefull, objects you delete in the layout will stay in the project. You have to delete them from the project file system (the frame on the top right by default in C2)
- Try to have more meaningfull names for your sprites than "Image5", "Sprite", or "Sprite2", it will help you a lot as your project grows.
- don't repeat the "rotate" action like this. Imagine you have to change how you rotate in the future, or if you decide that it won't be 1 rotation, but a full animation (rotation speed, acceleration, blink when rotating, ...). You would have to do the "rotation" feature 4 times (or more if you use other controls). Instead, call a "function" witch will perform the rotation, like this :

I didn't change the way you capture the inputs, but you'll notice that this way let me move the "resize the white sprite" event inside the function, instead of being performed every tick. This is of no impact in a test like this, but in a project, try to evaluate the least possible number of things every tick, this is the best way to keep your framerate around 60fps.
B
17
S
8
G
4
Posts: 461
Reputation: 6,157


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 52 guests