How do I

Get help using Construct 2

Post » Thu Feb 23, 2017 12:36 pm

Hi,
I have a main touch event with some action and under it there is a sub-event that contains lot of actions and system waits, now when touch event is raised again(2nd time) before completion of the sub-event(from first touch) I want to stop the sub-event ( from first touch) and start over. How do I achieve it.


Thanks
B
7
S
3
Posts: 7
Reputation: 591

Post » Thu Feb 23, 2017 5:46 pm

What are the 'waits' used for ?
B
33
S
18
G
28
Posts: 2,455
Reputation: 20,874

Post » Thu Feb 23, 2017 6:52 pm

shaurya wrote:Hi,
I have a main touch event with some action and under it there is a sub-event that contains lot of actions and system waits, now when touch event is raised again(2nd time) before completion of the sub-event(from first touch) I want to stop the sub-event ( from first touch) and start over. How do I achieve it.


Thanks


You can use a global variable as a trigger on your sub events just like on the main event.
Banned User
B
23
S
6
G
58
Posts: 1,229
Reputation: 34,540

Post » Fri Feb 24, 2017 3:38 am

99Instances2Go wrote:What are the 'waits' used for ?


waits are system waits, like wait 5 second before another action is executed.
B
7
S
3
Posts: 7
Reputation: 591

Post » Fri Feb 24, 2017 3:47 am

When user touches sprite for second time I want to stop execution of that event[from first touch] and start over.
B
7
S
3
Posts: 7
Reputation: 591

Post » Fri Feb 24, 2017 4:12 am

shaurya wrote:When user touches sprite for second time I want to stop execution of that event[from first touch] and start over.


Use a global variable as a trigger.

Global variable Trigger = 0

Main event:

Do something:
On Trigger =1

Sub event:

Wait so many seconds:
On Trigger =0


On Sprite touched: Set Trigger =1
Trigger = 0

On Sprite touched: Set Trigger =0
Trigger = 1

You can use global variables in sub events to trigger only certain actions just like you can for main events.
Banned User
B
23
S
6
G
58
Posts: 1,229
Reputation: 34,540

Post » Fri Feb 24, 2017 5:39 am

Global variable is best friend to this... just like @lamar example. that is perfectly what you need :D
B
79
S
31
G
7
Posts: 148
Reputation: 9,179

Post » Fri Feb 24, 2017 8:37 am

Global is not gonna be enough, when using 'waits'. shaurya speaks about '5 seconds' postpones.
Then postponed actions will run anyway, when their time has come, independent of the global.

Thing is, i dont know how to stop a postponed action. You can stop postponed conditions. But then you need to use a 'timer' instead of 'wait'.

Allow me again to beg you for not using 'wait'.
B
33
S
18
G
28
Posts: 2,455
Reputation: 20,874

Post » Fri Feb 24, 2017 12:13 pm

Global variable is not enough when you have event with lot of actions and waits. Actually my event is around 20 seconds long. I want to exit event execution, say when its half way though like 10 second when same event is raise again.

My event looks like this:

Touch|On tap gesture on sprite8 : textbox1: set visible
system: wait 5 seconds
textbox2: set visible
system: wait 2 seconds
sprite3: set visible
system: wait 3 seconds
sprite5: set animation frame to 3
system: wait 4 seconds
textbox4: set font color to rgb(0,0,255)
system: wait 4 seconds
sprite5: set animation frame to 2
...
B
7
S
3
Posts: 7
Reputation: 591

Post » Fri Feb 24, 2017 1:06 pm

lamar, thx 4 deleting that last post. Appreciated.

As i said, i dont know how to stop postponed actions. But you can stop timed conditions.

https://www.dropbox.com/s/h3f1i61ohw40r ... .capx?dl=0

To complicated? Plz give me a better way, would really like to know.
B
33
S
18
G
28
Posts: 2,455
Reputation: 20,874

Next

Return to How do I....?

Who is online

Users browsing this forum: MoscowModder, Yahoo [Bot] and 6 guests