Odd or Even Game

  • I'm having trouble with something. In the example I'm adding, please can you just press space, and let me know what you see happen.

    The numbers are meant to change each time, but they only seem to change when it switches between odd and even (You'll understand when you load it).

    I've tried it a couple of different ways, and it's just not working. The code in question is shown at the bottom, events 3 to 30.

    Link

    Help please!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • That is due trigger once event at 29 and 30. It triggers only once when the conditions are true, so unless the variable changes to another one in between it does not call the function. Instead of having a global variable like that to handle things, why not put the function calls directly at the event that is triggered by the spacebar press?

  • Instead of having a global variable like that to handle things, why not put the function calls directly at the event that is triggered by the spacebar press?

    Thanks, I tried that and it didn't work <img src="smileys/smiley36.gif" border="0" align="middle" /> I also tried having the variable switch to another number before picking a random number, but it didn't change anything.

  • If I disable the "Trigger Once" command, the event loops, and quickly changes the numbers. If I press 1 or 2 on the keypad, it triggers once, but the event changes. Why does this not work?

  • > Instead of having a global variable like that to handle things, why not put the function calls directly at the event that is triggered by the spacebar press?

    Thanks, I tried that and it didn't work <img src="smileys/smiley36.gif" border="0" align="middle" /> I also tried having the variable switch to another number before picking a random number, but it didn't change anything.

    Worked for me:

    <img src="http://dl.dropbox.com/u/19921470/odd_even_fix.PNG" border="0" />

  • You have a lot of repetition going on there. Both Odd and Even functions can be reduced to 2 events.

    oddEvenPlanes.capx (r122)

  • vee41, Brilliant! I didn't know about choose. That will come in useful :) Thank you very much!

  • Wow! Thanks I'll look into this. Very clever... though I barely understand it. Never used parameters before, nor the ? or : symbols in expressions. Still got a lot to learn.

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