Alice Community  

Go Back   Alice Community > General Discussion > Questions and Comments

Reply
 
Thread Tools Display Modes
More on mouse events
Old
jrrTolkien
Senior Member
 
jrrTolkien's Avatar
 
Status: Offline
Posts: 166
Join Date: Feb 2014
Location: Middle-Earth (Merrimack, NH)
Lightbulb More on mouse events - 09-22-2014, 08:14 AM

Is there a way to store the values of the objects the mouse selects in a variable? I usually have to make an event for when the mouse clicks on each single object, which gets kinda sloppy. If I said when the mouse clicks on anything, and stored what the mouse clicked in a variable, I could use if/else statements to trigger the right method, making it much easier to code when there are a lot of objects I want the user to click.

-jrr


Arwen: I would rather share one lifetime with you than face all the Ages of this world alone.

-April Signature
   
Reply With Quote
Maybe!
Old
MrMoke
Senior Member
 
MrMoke's Avatar
 
Status: Offline
Posts: 501
Join Date: Sep 2007
Location: Austin, Texas
Default Maybe! - 09-22-2014, 08:49 AM

Add an Object Parameter to the Method you wish to call. Drag the method name into the event, and there will be a dropdown for "what was clicked".

It obviously gets more complicated if you have different types of objects because the parts are name differently.
Attached Files
File Type: a2w demo.a2w (1.78 MB, 3 views)

Last edited by MrMoke; 09-22-2014 at 09:21 AM.
   
Reply With Quote
Neat!
Old
jrrTolkien
Senior Member
 
jrrTolkien's Avatar
 
Status: Offline
Posts: 166
Join Date: Feb 2014
Location: Middle-Earth (Merrimack, NH)
Talking Neat! - 09-22-2014, 08:59 AM

Great! That'll make things a lot easier (I hope ) Thanks!

-jrr


Arwen: I would rather share one lifetime with you than face all the Ages of this world alone.

-April Signature
   
Reply With Quote
Oops-
Old
MrMoke
Senior Member
 
MrMoke's Avatar
 
Status: Offline
Posts: 501
Join Date: Sep 2007
Location: Austin, Texas
Default Oops- - 09-22-2014, 09:05 AM

Forgot the Demo

Last edited by MrMoke; 09-22-2014 at 09:19 AM. Reason: Again Updated Demo for Clarity
   
Reply With Quote
Old
jrrTolkien
Senior Member
 
jrrTolkien's Avatar
 
Status: Offline
Posts: 166
Join Date: Feb 2014
Location: Middle-Earth (Merrimack, NH)
Default 09-22-2014, 10:18 AM

Happens to me all the time in emails! I keep forgetting the attachments!


Arwen: I would rather share one lifetime with you than face all the Ages of this world alone.

-April Signature
   
Reply With Quote
Updated mouse events
Old
AliceMaster00
Senior Member
 
AliceMaster00's Avatar
 
Status: Offline
Posts: 167
Join Date: Oct 2011
Location: You know that gap between the bottom of your dresser and the floor? Yeah, there.
Default Updated mouse events - 09-23-2014, 04:09 PM

So, I took a look at the demo and found that even if you don't click on the t-rex, the action is still performed (its leg moves anyways). I messed around with the world and fixed the issue. There needs to be a method that checks what object was clicked, but it can't grab the variable that is in the parameter in a different method. So, all you do is link the object within the parameter to a world variable, preferably a string, so that the method that initiates the action upon the object that was clicked knows what action to initiate. You can skim through the coding to see what I did. Let me know if it was helpful. There are two dinos. If you click the trex, then the trex nods, if you click the triceratops, then the triceratops nods it's head, but, if you click on the ground or the sky, or any object that is not the trex or the triceratops, then nothing happens.
Attached Files
File Type: a2w demo.a2w (2.31 MB, 1 views)


What a piece of work is a man? How noble in reason, how infinite in faculties, in form and in motion, how express and admirable how like an angel! What apprehension oh how like a god! The beauty of thee world, the paragon of animals, and yet- to me, what is this quintessence o' dust? Man delights, not me. Nor woman either, nor woman either.
   
Reply With Quote
Good Job
Old
MrMoke
Senior Member
 
MrMoke's Avatar
 
Status: Offline
Posts: 501
Join Date: Sep 2007
Location: Austin, Texas
Thumbs up Good Job - 09-23-2014, 08:40 PM

A major portion of successful design is to create efficient and creative ways to pass information between modules. Global variables are a good way to make information accessible.
My original demo was just a quickie to show how to pass one of the same type of clicked objects into a method.

This one took a few more minutes, but accomplishes the same using lists of similar objects.

There's always a way, but you have to plan it first
Attached Files
File Type: a2w DinoClickChecker.a2w (2.87 MB, 4 views)
   
Reply With Quote
Old
AliceMaster00
Senior Member
 
AliceMaster00's Avatar
 
Status: Offline
Posts: 167
Join Date: Oct 2011
Location: You know that gap between the bottom of your dresser and the floor? Yeah, there.
Default 09-25-2014, 07:40 AM

Nicely done! Ha ha, I never thought of using lists. That's probably why I'm having so much trouble with my weapon swapping system.


What a piece of work is a man? How noble in reason, how infinite in faculties, in form and in motion, how express and admirable how like an angel! What apprehension oh how like a god! The beauty of thee world, the paragon of animals, and yet- to me, what is this quintessence o' dust? Man delights, not me. Nor woman either, nor woman either.
   
Reply With Quote
Wow...im dumb
Old
RavenOfCode
Senior Member
 
RavenOfCode's Avatar
 
Status: Offline
Posts: 408
Join Date: Oct 2013
Location: Northern Virginia
Default Wow...im dumb - 09-25-2014, 08:43 PM

I saw your comment and I realized that's a smart idea... a weapon system with lists...


Stuff + Other Stuff + Different Other Stuff = Things :)

My best Alice game:

Clash of the Cubes (an arena fighting game):
http://www.alice.org/community/showthread.php?t=10738&highlight=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 ©2019, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.