What is the differnce?

For questions about using Classic.

Post » Sat Mar 06, 2010 12:57 am

What is the difference between

V2:
http://www.box.net/shared/6ufzkqmor1

and V3
http://www.box.net/shared/1e3xhgkcz1

This type thing is the hardest for me to understand about construct. I have no clue when you want to add a "New sub event" as in V2 or lump them together as in V3


BTW neither does what I want it to do hence my confusion. See:
Angle of Motion Question
viewtopic.php?f=3&t=5903&p=47171#p47171
B
28
S
8
G
8
Posts: 530
Reputation: 7,154

Post » Sat Mar 06, 2010 2:25 pm

Logic-wise, version three is asking:
If the user clicks and releases the button AT THE SAME TIME! :O

Which is impossible.

The sub-event one is kinda doing the same thing. Sub-events are very useful for compressing code where one or more conditions are common to all of them.
A good example would be instead of using the following four events:

+ System: Is global variable 'Var' Equal to 1
+ MouseKeyboard: Key Up arrow is down
-> Sprite: Set 'Direction' to "Up"
+ System: Is global variable 'Var' Equal to 1
+ MouseKeyboard: Key Up arrow is down
-> Sprite: Set 'Direction' to "Up"
+ System: Is global variable 'Var' Equal to 1
+ MouseKeyboard: Key Left arrow is down
-> Sprite: Set 'Direction' to "Left"
+ System: Is global variable 'Var' Equal to 1
+ MouseKeyboard: Key Left arrow is down
-> Sprite: Set 'Direction' to "Right"

You could use one event with four sub-events like so:

+ System: Is global variable 'Var' Equal to 1
>>>>+ MouseKeyboard: Key Up arrow is down
>>>>-> Sprite: Set 'Direction' to "Up"
>>>>+ MouseKeyboard: Key Down arrow is down
>>>>-> Sprite: Set 'Direction' to "Down"
>>>>+ MouseKeyboard: Key Left arrow is down
>>>>-> Sprite: Set 'Direction' to "Left"
>>>>+ MouseKeyboard: Key Left arrow is down
>>>>-> Sprite: Set 'Direction' to "Right"

I hope that's legible, a subevent triggers when the event its below is true, in this case, if Var equals 1, then it runs the arrow events. There are other handy uses for them too but it gets a little situation specific I find. I'll be happy to try and explain it better if you didn't understand my ramblings.
In any case, I fixed up your angle of motion cap without using any subevents anyway :wink: Go have a look if you haven't already
B
3
S
2
G
5
Posts: 351
Reputation: 2,377

Post » Sat Mar 06, 2010 2:55 pm

So the sub event is only for visual clarity? I was thinking it to be more like If the Event was true then continue with the sub event.

If that is true we could really use a case statement.

Oh and thank you for taking the time to explain that Arcticus.
B
28
S
8
G
8
Posts: 530
Reputation: 7,154

Post » Sat Mar 06, 2010 2:56 pm

I use subevents as example to check if sounds GV is 1 and if it is play sound

Simple as that
B
11
S
3
G
4
Posts: 622
Reputation: 3,186

Post » Sat Mar 06, 2010 3:46 pm

[quote="Guyon":3s232xki]So the sub event is only for visual clarity? I was thinking it to be more like If the Event was true then continue with the sub event.[/quote:3s232xki]

No, sub-events are not just for visual clarity. Yes, you can use them that way if you want to, but what you were thinking is correct... if the root event is true then the sub-event will run. If the root event is not true, then the sub-event will be skipped.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Sat Mar 06, 2010 4:55 pm

Thanks deadeye, I see that now after doing a test. Which confuses me why my bad program ran both sub events at the same time.
I have so much to learn about Construct. In a few cases real code is much easier to follow. :lol:
B
28
S
8
G
8
Posts: 530
Reputation: 7,154


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests