Odd or Even Game

Get help using Construct 2

Post » Sat Mar 16, 2013 7:00 pm

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!
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
68
S
8
G
6
Posts: 930
Reputation: 9,358

Post » Sat Mar 16, 2013 7:20 pm

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?
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Sat Mar 16, 2013 7:41 pm

[QUOTE=vee41] 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?[/QUOTE]

Thanks, I tried that and it didn't work I also tried having the variable switch to another number before picking a random number, but it didn't change anything. AnD4D2013-03-16 19:41:50
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
68
S
8
G
6
Posts: 930
Reputation: 9,358

Post » Sat Mar 16, 2013 8:09 pm

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?
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
68
S
8
G
6
Posts: 930
Reputation: 9,358

Post » Sat Mar 16, 2013 8:18 pm

[QUOTE=AnD4D] [QUOTE=vee41] 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?[/QUOTE]

Thanks, I tried that and it didn't work I also tried having the variable switch to another number before picking a random number, but it didn't change anything. [/QUOTE]

Worked for me:

B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Sat Mar 16, 2013 8:26 pm

You have a lot of repetition going on there. Both Odd and Even functions can be reduced to 2 events.
oddEvenPlanes.capx (r122)
B
54
S
28
G
18
Posts: 1,520
Reputation: 25,020

Post » Sat Mar 16, 2013 8:26 pm

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

Nintendo Wii U Developer using Construct 2
B
68
S
8
G
6
Posts: 930
Reputation: 9,358

Post » Sat Mar 16, 2013 8:55 pm

Wow! Thanks @ramones. 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.
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
68
S
8
G
6
Posts: 930
Reputation: 9,358


Return to How do I....?

Who is online

Users browsing this forum: makkancs, Matthew de and 38 guests