Alice Community

Alice Community (http://www.alice.org/community/index.php)
-   How do I...? (http://www.alice.org/community/forumdisplay.php?f=16)
-   -   How do I create an two events for one object? (http://www.alice.org/community/showthread.php?t=6162)

1101Student 03-22-2011 11:46 PM

How do I create an two events for one object?
 
Hi gurus,

I have an object that when [U]clicked on[/U] does a method. I want the same object when clicked on AGAIN to perform a second method.

I have considered using a boolean (true/false) statement but am unsure how to write such a code. An example would be great.

Regards,

reuben2011 03-23-2011 05:13 PM

Assuming that your using a method named onClick for the "when an object is clicked" and you have a variable named alreadyClicked whose initial value is false, this is what the code for onClick would look like.

[CODE]
if alreadyClicked == false
{[INDENT]alreadyClicked set value to true[/INDENT][INDENT]//put methods for the first time it's clicked[/INDENT]}
else
{[INDENT]//put methods for the second time it's clicked[/INDENT]}
[/CODE]

If you want a screenshot of the above code to help you out, just let me know. :cool:


All times are GMT -5. The time now is 06:46 AM.

Copyright ©2019, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.