Alice Community  

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

Reply
 
Thread Tools Display Modes
How to use the mouse distance from left edge?
Old
Ben_the_Geek
Guest
 
Status:
Posts: n/a
Default How to use the mouse distance from left edge? - 10-05-2009, 09:06 AM

Hello,
I was wondering how to use the function mouse distance from left edge in my code? what would thiks be used for?
   
Reply With Quote
Old
x2495iiii
Super Moderator
 
x2495iiii's Avatar
 
Status: Offline
Posts: 3,508
Join Date: Dec 2008
Location: Somewhere in the Continental U.S.
Default 10-05-2009, 07:59 PM

It'd be used to do just that: track where the mouse cursor is on the screen. It can be used to have the camera follow the mouse, or to have objects move with the mouse.
   
Reply With Quote
Old
Ben_the_Geek
Guest
 
Status:
Posts: n/a
Default 10-06-2009, 09:22 AM

i want to make a object appear when it goes a certain distance away from the left edge....how would i use this function to accomplish my goal?
   
Reply With Quote
Old
x2495iiii
Super Moderator
 
x2495iiii's Avatar
 
Status: Offline
Posts: 3,508
Join Date: Dec 2008
Location: Somewhere in the Continental U.S.
Default 10-06-2009, 03:40 PM

First you should make a calibrator. To do that, create two variables, one called TopDist and one called LeftDist. Then, create a method that loops constantly, it can be a "While true," a "loop infinity times," or a "while the world is running" in the "during" part. Inside this method, have the variables both set their values to one. Then, go to the world's function tab and drag the "cursor distance from left edge" in place of the number one for the leftDist variable, and do the same for the topDist variable, but with the "distance from top edge" function.

Now, if you play your world with the two varialbes in sight behind the Playing Window, you should be able to see what distance Alice recognizes the mouse is away from each edge.

To make an object appear, just put in a "while leftDist > x" or "while leftDist < x" method, then have it trigger the method you want, like the object appearing.
   
Reply With Quote
Old
Ben_the_Geek
Guest
 
Status:
Posts: n/a
Default 10-06-2009, 08:13 PM

wow, thats pretty dang cool! Thanks so much! This helps me out a ton.

Thank you again!

Ben the Geek
   
Reply With Quote
Old
Ben_the_Geek
Guest
 
Status:
Posts: n/a
Default 10-07-2009, 08:52 AM

When i watch my variables they seem to stay at a value of 1.

What am i doing wrong?
   
Reply With Quote
Old
Ben_the_Geek
Guest
 
Status:
Posts: n/a
Default 10-07-2009, 10:01 AM

Nevermind i got it to work right. thanks
   
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 ©2023, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.