Learn Create Your Own Split Screen

Next Page

Any decent game is going to involve either the mouse or touch. At the moment, you might be using S2JS on a device with a mouse, or maybe a touch-enabled tablet, or maybe a device that can do both.

On the face of it, you might think detecting the mouse would be very similar to detecting touch.

And it sort of is. But with a couple of really fundamental differences:

Mouse Touch
A mouse moves around the screen and can hover without being clicked. A finger touch doesn't occur until it actually touches - the computer can't see your finger waving around the same way a mouse can.
There's only one mouse, so it can only be in one place at a time. Most devices can track multiple touch locations at the same time.
There's usually multiple buttons on a mouse, so there's different types of click. A touch is a touch - it can't tell which finger you're using.

You may recall how keystrokes on the keyboard cause 'keydown' events to occur.

Touch and mouse work a similar way, but each one has slightly difference events because of the differences listed above.