How do I change animation frames under certian conditions?

Get help using Construct 2

Post » Sun Jul 20, 2014 12:43 am

I'm working on my Dragon game and I was wondering if anyone knew how I could change animation frames only under certain conditions.

Mainly, when a fireball hits a target it briefly turns into a flame before being destroyed and when the baby dragon takes damage he changes color 3 lives=Green, 2 lives=Yellow, 1 life= Red.

Thanks!
B
10
S
1
Posts: 69
Reputation: 641

Post » Sun Jul 20, 2014 12:49 am

Let's assume your baby dragon is an animation composed of 3 different frames of 3 different colors (one for each number of lives). Set the speed of this animation to 0 (so frames don't go by and a single frame is displayed).

In the condition "Fireball on collision with baby dragon" (however you made it in your project) make sure to remove one HP from your dragon (probably in its instance variable HP) and then add subevents checking out what is the current value of this variable.
According to the value, set the appropriate frame.

You're likely to have a more precise answer if you post/attach your current project to the post asking for help, since it's not easy to guess out what you've made so far.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
293
S
117
G
96
Posts: 7,310
Reputation: 71,069

Post » Sun Jul 20, 2014 2:55 am

Kyatric wrote:Let's assume your baby dragon is an animation composed of 3 different frames of 3 different colors (one for each number of lives). Set the speed of this animation to 0 (so frames don't go by and a single frame is displayed).

In the condition "Fireball on collision with baby dragon" (however you made it in your project) make sure to remove one HP from your dragon (probably in its instance variable HP) and then add subevents checking out what is the current value of this variable.
According to the value, set the appropriate frame.

You're likely to have a more precise answer if you post/attach your current project to the post asking for help, since it's not easy to guess out what you've made so far.


Okay, I've included my file. It's kind of like an arcade game where you drag and drop the baby dragon to release fireballs at soldiers who are intruding in your cave but letting the prince and princess come to you as they will restore your ammo. And unfortunately I can't include the file to their post due to size so here's a dropbox link: https://www.dropbox.com/s/kn4ap8xz1sl2a ... Beta4.capx
B
10
S
1
Posts: 69
Reputation: 641

Post » Sun Jul 20, 2014 3:35 am

So as I was saying, you first need to set the animation speed to 0 for all your images "MeanKinght", "ReflectKnight", "CrossbowKnight", "BabyDragon", "Princess" and "Prince" as well as "Arrow".

Go into the image editor, click the "Default" name of each animation and modify the "Speed" property.
Sounds like you already made the rest.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
293
S
117
G
96
Posts: 7,310
Reputation: 71,069

Post » Sun Jul 20, 2014 7:25 pm

Okay it's working, and would I do something similar when I want the sprites to turn into flames (which is sprite 1) when the fireball collides with them?
B
10
S
1
Posts: 69
Reputation: 641


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 46 guests