Alice Community

Alice Community (
-   How do I...? (
-   -   How do I create an two events for one object? (

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.


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.

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

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.