Mouse Module (last update 10/05/01)

Description:

The module adds mouse support to your game/animation. This includes reading the position and state of the mouse, and triggering mouse actions on sprite and layer objects.

To use:

The code can be linked in to your script by adding this line to the <HEAD> section of your document:

<script language="Javascript" src="gamelib_mouse.js"></script>

You then instantiate the mouse by adding the following to your script:

myMouse=Ms_initmouse();

List of methods for mouse module

disable
enable

List of properties for mouse module

mousedown
onstate
over
x
xoff
y
yoff
z

Descriptions of methods

MethodParametersDescription
disable(none)This disables the sprite mouse event triggers. This may be of use if you don't actually need the mouse very often and wish to save CPU cycles. While the mouse handler is optimized, it's still better not to have it enabled if you don't need it! The mouse object you have set up will still report the mouse position and button state, but will not update the over property and the sprite event triggers will not function
enable(none)This is called when you first initialize the mouse object, and can be used to re-enable the mouse event triggers if you disable them

Descriptions of properties

PropertyData TypeRead/WriteDescription
xNumericRThe x position of mouse _RELATIVE_ to Sp_xoffset (see sprite docs about this global variable)
yNumericRThe y position of mouse _RELATIVE_ to Sp_yoffset (see sprite docs about this global variable)
mousedownBooleanRUsed to determine whether the mouse button is pressed down
overObjectRIf not NULL, then this is the sprite or layer the mouse pointer is over. Sprites and layers actually have their own mouse event triggers, see the sprite docs or layer docs for details
xoffNumericRThe position of the mouse in the x axis relative to sprite/layer it's over
yoffNumericRThe position of the mouse in the y axis relative to sprite/layer it's over
zNumericRThe z index of the sprite/layer the mouse is over. Used internally
onstateBooleanRUsed internally