[SOLVED]Variable double increments without action for such

Just started using Construct 2? Post your questions here

Post » Thu Jul 24, 2014 6:26 pm

Hello,

I have been trying to come up with a way to create dialogues as easy as possible and without too much hassle. I came up with a way that I think might actually work well but the problem is that something is wrong (I am probably doing something stupid but I couldn't figure it out for the past 2 hours).

The way the .capx is setup is that when you move within 50px of the NPC sprite (red rectangle) and click on it, another sprite (which supposedly would be a sprite that contains the dialogue) appears at the bottom left of the screen. When you click once on that new sprite it changes animations (it is a subtle change). There is a variable inside the sprite called dialogueStep that increments by 1 every time you click.

Problem is, when I click once on the sprite it sets the variable from 0 to 2 without first doing 0 -> 1. At first I had it setup to "add to value" but then thought that might be the problem so I changed it to "set to value" and I manually set the value. Both ways end up the same way.

Can anyone take a look at the file please and let me know what I am doing wrong?

Thank you very much in advance.
You do not have the required permissions to view the files attached to this post.
Last edited by Vallar on Thu Jul 24, 2014 7:16 pm, edited 1 time in total.
B
19
S
7
Posts: 161
Reputation: 1,751

Post » Thu Jul 24, 2014 6:33 pm

Try adding a system wait = 0.1 action to your on-click events.
B
11
S
2
Posts: 86
Reputation: 1,001

Post » Thu Jul 24, 2014 6:39 pm

Done, same thing. No change what so ever.
B
19
S
7
Posts: 161
Reputation: 1,751

Post » Thu Jul 24, 2014 6:54 pm

Sorry. For clarifiaction, your code first sets it to 1, and the very next event is 'if this value is 1' ... which sets it to two.

You need a conditional check somewhere -- you can make it a ELSE system event.
B
11
S
2
Posts: 86
Reputation: 1,001

Post » Thu Jul 24, 2014 7:02 pm

I think you are making the common mistake pointed out (with solutions) here:
https://www.scirra.com/tutorials/292/gu ... t-features
B
11
S
2
Posts: 86
Reputation: 1,001

Post » Thu Jul 24, 2014 7:07 pm

OK, I tried something else.

I tried condition:
Event 1 = Mouse Left click on Sprite & dialogueStep = 1 > Move to animation frame 1
Event 2 = Mouse Left click on Sprite & dialogueStep = 2 > Move to animation frame 2
Event 2 = Mouse Left click on Sprite & dialogueStep = 3 > Move to animation frame 3

Still doing the same thing on 1 click only. How can that be when if I click ONCE the only event true would be the first one and the second one won't be true because the click happened once not more than that?

Wouldn't it check all 3 every click? And see which condition is true execute it and then wait for another click?

That said, I didn't understand what you mean by make it an else system event. Sorry.
B
19
S
7
Posts: 161
Reputation: 1,751

Post » Thu Jul 24, 2014 7:10 pm

See attached.

As has been pointed out, events are run sequentially, so without an Else, all your actions are valid.
You do not have the required permissions to view the files attached to this post.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
131
S
29
G
81
Posts: 5,328
Reputation: 56,630

Post » Thu Jul 24, 2014 7:14 pm

Ahh, got it. Sorry I didn't see you edited your post a 2nd time. I hit post too quickly as it seems.

Thank you very very much for fixing it and for linking that :D
B
19
S
7
Posts: 161
Reputation: 1,751


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests