Custom Cast Cursors (P/C)

Date:    Wed, 29 Oct 1997 22:42:43 -0600
From:    Jeff Tobler 
Subject: Re: Custom cursor selection point [Dir 5 mac]

> a) does anybody know a better/different way to impliment custom cursors
> larger than 32x32?
>
> b) does anybody know, using this method or any other, how to set the
> actual selection point of the cursor( I'm not sure what the tech term is-
(a) Its easier to create a parent script to handle cast member cursors. Check out the scripts below.



--===================================================================
-- PUT THE FOLLOWING IN A MOVIE SCRIPT
--===================================================================
  on startMovie
      new (script "CC Hack")
      global gPCClrCurs
      mSetClrCurs gPCClrCurs, 2
      pass
  end

--===================================================================
-- PUT THE FOLLOWING IN A PARENT SCRIPT
--===================================================================
  on new me
    global gPCClrCurs
    set gPCClrCurs = me
    puppetSprite 48, true
  end new

  on mSetClrCurs me, CursorCastNum
    --  simulate color cursor using channel 48 and a color sprite 16x16
    cursor 200
    set the castNum of sprite 48 = CursorCastNum
    if not getOne(the actorList, me) then add(the actorList, me)
    stepFrame me
  end mSetClrCurs

  on mSetDefCurs me
    --  reset to defualt (or system) cursor
    cursor 0
    set the castNum of sprite 48 = 0
    deleteOne(the actorList, me)
  end mSetDefCurs

  on stepFrame me
    set the loc of sprite 48 = point(the mouseH, the mouseV)
  end stepFrame

--===================================================================
--===================================================================
b) If you're wanting to have the mouse click register on a specific pixel of the cursor, you'll have to reverse the process. Offset the bitmap cursor from the mouseLoc according to your desired 'hot point'.
>
> a) does anybody know a better/different way to implement custom cursors
> larger than 32x32?
>
> b) does anybody know, using this method or any other, how to set the
> actual selection point of the cursor( I'm not sure what the tech term is-
a) Its easier to create a parent script to handle cast member cursors. Check out the scripts below.

--===================================================================
-- PUT THE FOLLOWING IN A MOVIE SCRIPT
--===================================================================
  on startMovie
      new (script "CC Hack")
      global gPCClrCurs
      mSetClrCurs gPCClrCurs, 2
      pass
  end

--===================================================================
-- PUT THE FOLLOWING IN A PARENT SCRIPT
--===================================================================
  on new me
    global gPCClrCurs
    set gPCClrCurs = me
    puppetSprite 48, true
  end new

  on mSetClrCurs me, CursorCastNum
    --  simulate color cursor using channel 48 and a color sprite 16x16
    cursor 200
    set the castNum of sprite 48 = CursorCastNum
    if not getOne(the actorList, me) then add(the actorList, me)
    stepFrame me
  end mSetClrCurs

  on mSetDefCurs me
    --  reset to default (or system) cursor
    cursor 0
    set the castNum of sprite 48 = 0
    deleteOne(the actorList, me)
  end mSetDefCurs

  on stepFrame me
    set the loc of sprite 48 = point(the mouseH, the mouseV)
  end stepFrame

--===================================================================
--===================================================================
If you're wanting to have the mouse click register on a specific pixel of the cursor, you'll have to reverse the process. Offset the bitmap cursor from the mouseLoc according to your desired 'hot point'.

In other words, you can't set the 'hot point' of the fake cursor. Instead, move the real cursor (by moving the loc of the fake cursor) into the desired 'hot point' position.

For instance, (see example above) under normal circumstances the mouse will be in the center of this fake cursor.


--===================================================================
  on stepFrame me
    -- This will effectively center the 'hot point' on the fake cursor
    set the loc of sprite 48 = point(the mouseH, the mouseV)
  end stepFrame
--===================================================================
But by offsetting the 'tracking loc' by -20 pixels (for a 40x40 pixel cursor), the cursor is now on the upper edge of the fake cursor, and consequently, so is your 'hot point'.

--===================================================================
  on stepFrame me
    -- assuming your bitmap is 40x40 pixels, this will put the
    -- 'hot point' in the upper-left corner.
    set the loc of sprite 48 = point(the mouseH - 20, the mouseV -20)
  end stepFrame
--===================================================================
Cheers,
Jeff Tobler

The Riddle of the Sphinx!
http://www.sphinx3d.com

FREE Crusty, Dirty Shapes & Textures...
http://www.sphinx3d.com/relics.html