Using same button/command to different events

For questions about using Classic.

Post » Fri Sep 02, 2011 12:47 pm

I have tried to learn the program myself as best as possible without asking any help. But now I have run into a same problem so many times that I really need to ask some.

So the problem is very simple actually:
I would like to know how to, for example turn something on and off with a same command. For example when pressin "escape", "pause menu" is set to "visible". And when pressing "escape" again, it's set to "invisible".

I made this simple example file if someone is kind enough to show how it works:
boxtest.cap

So in this example file there is a blue box. Now when You press a "Enter" the blue box is set to visible. So what I wold like to happen is when You press "Enter" again, the blue box is set to "invisible".
And so that this keeps on going everytime when pressin "Enter", like in a "pause menu" case.

Btw, heres the latest video of the project Im working on

Thanks

Jonez
B
4
G
1
Posts: 6
Reputation: 812

Post » Fri Sep 02, 2011 4:27 pm

Here is your amended .cap. Hope it's what you want.


Event shown below:



zenzenox982011-09-02 16:59:01
If your vision so exceeds your ability, then look to something closer.
Moderator
B
120
S
28
G
68
Posts: 4,839
Reputation: 48,279

Post » Sat Sep 03, 2011 11:22 am

This works. Thank You.
Now I have to figure out how to make it work with more complicated stuff like sounds and etc.
But now that I have somekind of a start It shouldnt be too hard. Thanks again
B
4
G
1
Posts: 6
Reputation: 812

Post » Sat Sep 03, 2011 7:59 pm

The approach I use is to have a private variable for the menu, which is toggled with the key.

on key enter pressed - set object.value('menu') to 1 - object.value('menu')

Now with this you can have event stacked under each value.

object.value('menu') = 0
        -make box invisible
        -enable player movement
        -disable mouse
        -disable mouse
        -disable menu events
        -disable etc

object.value('menu') = 1
        -make box visible
        -disable player movement
        -enable mouse
        -run menu events
        -etc


I actually made an example of this the other day
http://dl.dropbox.com/u/1487524/Scirra/setPositionMenuExample.cap
B
9
S
2
G
4
Posts: 346
Reputation: 2,726

Post » Sat Sep 03, 2011 11:21 pm

i'm always using same method as Steven
ie.

[code]+ MouseKeyboard: Key Space is down
-> Sprite: Add 1 to 'do_stuff'

+ Sprite: Value 'do_stuff' Equal to 0
-> "do something"
+ Sprite: Value 'do_stuff' Equal to 1
-> "do something else"
+ Sprite: Value 'do_stuff' Equal to 2
-> Sprite: Set 'do_stuff' to 0[/code]

It makes some kind of a loop :)
ImageImageImageImage
B
140
S
58
G
36
Posts: 2,547
Reputation: 31,170


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest