[SOLVED]Variable double increments without action for such

  • 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.

  • Try adding a system wait = 0.1 action to your on-click events.

  • Done, same thing. No change what so ever.

  • 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.

  • I think you are making the common mistake pointed out (with solutions) here:

    https://www.scirra.com/tutorials/292/gu ... t-features

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

  • See attached.

    As has been pointed out, events are run sequentially, so without an Else, all your actions are valid.

  • 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

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