Action dependence chain

For questions about using Classic.

Post » Fri Apr 09, 2010 12:00 pm

Hello.

I am trying to invoke a chain of actions after I push a button. When the button is pushed I want to call a function that does something [creates objects] and then another action that does something with all the objects created.

Here is a test cap:
http://www.box.net/shared/9jhikb4xqm
Here I simply create 5 objects and then count them and put the number in a message box to the user. The effect now is that the message box counts 0 object for the first time.
What I want to achieve is to create the objects first and count the objects [do stuff with them] later but as the part of the button clickage.

How do I do that? :cry:
B
2
G
2
Posts: 23
Reputation: 696

Post » Fri Apr 09, 2010 12:51 pm

It seems that the sprites are created at the end of the frame or the beginning of the next frame. However, just update the count value the next frame. In your cap file this could be done for example by adding a global variable.

>Is global variable 'SomeName' equal to 1
+[do the update]
+System: Set global variable 'SomeName' to 0
>On Go clicked
+System: Set global variable 'SomeName' to 1
>For ...
>(the expression from trigger once goes to [do the update], the event must be deleted here)

But pay attention to the order, because if you place "Is global..." after "On Go..." it would be called in the same frame, and you would have the wrong count again
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests