Next Button doesn't work more than once

Hello! I’m new here and didn’t find any topic about that… I might have missed it, if so, I’m sorry for the spam.

I’m using Wick Editor Version 1.19.3.

I’m trying to make a button next. There is a text block, when I click on the arrow, it goes to another text and if I click a second time, it goes to the next frame. My problem is that it only switches to the second text but then nothing happens. I can’t go to the next frame.

Here is how I’ve coded it:

Default:

man_text.setText("Oh! Hello there! \nAre you new here ? \n I've never seen you around.");

project.click = 0;

MouseClick:

project.click += 1;

if (project.click == 1) {
    man_text.setText("You came to rest and visit the island? \n Then you should visit the abandoned Pirate ship \n at the east. No need to thank me. Enjoy!");
}

else {
    gotoAndStop(6);
}

Thanks for your help, dear community!

I’m not sure if this will work, but i think i have a solution.

project.click += 1;
if (project.click === 1) {
man_text.setText(“You came to rest and visit the island? \n Then you should visit the abandoned Pirate ship \n at the east. No need to thank me. Enjoy!”);
}else if (project.click === 2) {
gotoAndStop(6);
}

What i did is, first, i put === instead of ==, i don’t know exactly what it changes but i think it checks if something is exactly what you ask it is.

Then i put an else if that checks if you’ve pressed the button twice, if you did, then it goes to the sixth frame.

Let me know if it works!

This is JavaScripts way of checking not only the value of a variable, but also the type. An number might be an integer (-1, 0 or 1) or, for instance, a float (-0.1, 0 or 1)
if both variables named floatZero and integerZero are, in fact, containing the number zero,
floatZero == integerZero will be true, but
floatZero ===integerZero will not.

Check W3Cschools for more info.
In this case, as you are assigning 0 and incrementing by 1 it will not make a difference.

Personally, I would not check if click equals 1. I would check if it is larger than zero: project.click > 0
Also, try not to use variable names can easily be thought to be used by something else. I don’t know, but I could see Wick using “click” for all kinds ot things in the code itself.
I would use: intCountClick (int for designating the type of variable and the rest to describe what it does.) That way, you can be certain you do not inadveredtly overwrite a variable or function used elsewhere in code.

regards,

Paui

1 Like

Hello! Thanks for your answer but I’ve already tried that and it doesn’t work either. :frowning:

The problem is, I need to click twice because I have two different events. First it has to show a text, and then, it has to go to another frame.

I tried

project.intCountClick += 1;

if (project.intCountClick === 1) {
    man_tex.setText("You came to rest and visit the island? \n Then you should visit the abandoned Pirate ship \n at the east. No need to thank me. Enjoy!");
}

else if (project.intCountClick === 2){
    gotoAndStop(6);
}

But it doesn’t work at all now. Nothing happens when I click. :frowning:

Why not set this code to the update script, wouldn’t that work?

gimme a sec I should’ve made an example…

Just place the code for moving/changing text in the update script, otherwise you can check out the example I've made because I was bored, by clicking here

inside the project, I included comments inside the code for you to be able to read, but really the code that the others have mentioned already works… If it’s placed in the update script…

1 Like

Thank you so much for your great help! I didn’t correct it yet but it looks a lot better than mine!

Thanks for your time everyone. :whale: :sunny: :two_hearts:

1 Like