Articles Archive
Articles Search
Director Wiki
 

Color cursors

October 30, 1997
by Pat McClellan

Dear Multimedia Handyman
I want to use a color bitmap (a Green "X" like in the X-Files) as the cursor in my Director movie. Is this possible?

Signed,

Agent X

Dear Agent X,

We can solve this mystery faster than you can say "alien autopsy." To accomplish this, you need to take care of 2 tasks:

  1. turn off the system cursor
  2. tie the position of your bitmap sprite to the mouseLoc

First, let's turn off the system cursor. In your startMovie handler, add the line "cursor 200". This eliminates the system cursor until you stop your movie or issue the command to restore it. (To restore the system cursor, use "cursor 0".)

Next, you need to take care of locking your bitmap cursor to the mouse's movements. Keep in mind, this is not a system cursor, so you'll need to place the bitmap in the score. Since you want the bitmap cursor on top of everything else on the screen, you need to place the bitmap member in the highest numbered sprite channel. I'll assume you're using Director 6, so place the bitmap in sprite channel 120 of the first frame of your movie. (Previous to D6, place it in sprite channel 48 and adjust your scripts accordingly.) Set the ink for this sprite to Background Transparent.

Now you need to puppet sprite channel 120. That means that we're taking control of what is displayed in that channel. We do this so that we don't have to put your bitmap in sprite channel 120 in every frame throughout your movie. Once it's established and puppeted, it will remain visible -- even if the score doesn't have anything in sprite channel 120. (In Director 5, puppeting also allows you to take control of the movement of the sprite.)

The Lingo is very simple. We need to repeatedly set the position of sprite 120 to the coordinates of the mouse as it moves around the screen. At any moment in time, we can describe the position of the mouse in terms of its horizontal position, "the mouseH", and its vertical position, "the mouseV". That position is written as "point(the mouseH, the mouseV)". Let's place that command in an "on idle" handler so that the cursor position is updated as frequently as possible.


on idle
  set the loc of sprite 120 to ¬
    point(the mouseH, the mouseV)
end

If you're not familiar with the "on idle" handler, read about it in your Lingo Dictionary. It is a very useful bit of code and it is perfectly suited to our task.

Keep in mind that if your movie goes to other movies, you'll need to repeat these steps. A puppeted sprite will not persist through this transition.

NOTE: To prevent the mouseCast and the rollOver from returning the sprite number of your color cursor, simply move the registration point for the cursor one pixel off of the bitmap.

And remember.... the truth is out there.

Patrick McClellan is Director Online's co-founder. Pat is Vice President, Managing Director for Jack Morton Worldwide, a global experiential marketing company. He is responsible for the San Francisco office, which helps major technology clients to develop marketing communications programs to reach enterprise and consumer audiences.

Copyright 1997-2017, Director Online. Article content copyright by respective authors.