SCI Programming.com
Welcome, Guest. Please login or register.
May 20, 2012, 08:44 PM
Home Gallery Arcade Chat Shop Search Help Login Register
Home Fan Made Games Sierra Games Tools Tutorials Member Sites
Developer Desktop

Home  >  SCI Community  >  SCI Programming  >  SCI Community How To's & Tutorials  >  Topic: How to determine the location of the mouse cursor « previous next »
Pages: [1] Print
Author Topic: How to determine the location of the mouse cursor  (Read 480 times)
Cloudee1
Just Another User
*

Karma: 2
Offline Offline

Posts: 576



Peekaboo!

$1819.00 Buckazoids
View Inventory
Give Money

Burger Time

coyaba ?id=1000008636
View Profile WWW
« on: Dec 24, 2006, 07:41 PM »

This is a question that I recently asked at Mega-Tokyo in which Troflip was good enough to write up some code illustrating that exact functionallity. This is a little snippet of code which I had hoped Troflip could enter here, but as he has not signed up yet and I really didn't want to lose this snippet as I plan to find a use for it, I have moved it here.

Troflip's code to get a view to follow the cursor broken up with small explanations added by me.

We first need to create an instance of an Actor, it needs to be an actor so that it can move around the screen. An init method has been included in the instance telling the actor to do what that script says.
Code:
(instance thing of Act
   (properties
      x 100
      y 100
      view 800
   )
   (method (init)
      (super:init())
      (self:setScript(thingScript))
   )
)
Now that the instance is complete, we also need to create the script which the instances init method references.
Code:
(instance thingScript of Script
   (properties)
   (method (doit)
      (var myEvent)
      (super:doit())
      (= myEvent Event:new(evNULL))
      (send client:setMotion(MoveTo (send myEvent:x) (send myEvent:y)))
      (send myEvent:dispose())
   )
)

 
...and then of course do (thing:init()) in your room's init method.
Logged

Chillin like a Villian

41134_goldld0.gif 49626_silverpropcomp.gif
Pages: [1] Print 
Home  >  SCI Community  >  SCI Programming  >  SCI Community How To's & Tutorials  >  Topic: How to determine the location of the mouse cursor « previous next »
Jump to:  
Page created in 0.099 seconds with 22 queries.
The SCI Programming Community
Copyright © 2007 - 2012, All Rights Reserved.
Forums Powered by SMF 1.1.16 | SMF © 2011, Simple Machines