Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
How do I create an two events for one object?
Old
1101Student
Guest
 
Status:
Posts: n/a
Default How do I create an two events for one object? - 03-23-2011, 12:46 AM

Hi gurus,

I have an object that when clicked on 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,
   
Reply With Quote
Old
reuben2011
Senior Member
 
reuben2011's Avatar
 
Status: Offline
Posts: 489
Join Date: Sep 2009
Location: Hawaii
Default 03-23-2011, 06: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
{
alreadyClicked set value to true
//put methods for the first time it's clicked
} else {
//put methods for the second time it's clicked
}
If you want a screenshot of the above code to help you out, just let me know.


Projects
-Escape the Kitchen
-That ninja animation
-Hill Collision

Upcoming Projects
-Some penguin adventure game?
   
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



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