Phaser home
Phaser AE
Open source
Phaser 4
Download
Learn
Editor
Tools
Docs
Examples
News
Log in
Examples
/
Input
/
Mouse
Phaser 4.1.0
Phaser 4 examples
Mouse
25
examples
Examples
25
Check Button Released
Detect which specific mouse button (left, right, middle, back, or forward) was released using pointer helper methods like leftButtonReleased and rightButtonReleased.
Circle Hit Area
Learn how to define a circular interactive hit area for a Sprite using a Geometric Circle shape and custom input callbacks.
Click Sprite
Enable input on a sprite to detect pointer events and change its visual state using tints during interactions.
Continuous Input Polling
Demonstrates how to use setPollAlways to trigger interaction events, like pointer over and out, even when the mouse is stationary but the object is moving.
Ellipse Hit Area
Demonstrates how to define a custom elliptical hit area for a sprite using a geometric shape and a contains check for pointer interaction.
Geometric Shape Hit Areas
Demonstrates how to define custom interactive hit areas for sprites using geometric shapes including Polygons, Circles, Ellipses, Rectangles, and Triangles.
Handle Multiple Overlapping Input Events
Demonstrates how to disable 'topOnly' input processing, allowing pointer events to trigger on all overlapping interactive objects simultaneously instead of just the top-most one.
Input Interactivity with Sprite Origins
Demonstrates how setting different origin points on interactive Sprites affects their hit detection and mouse hover areas.
Input Top Only
Demonstrates how to use the input topOnly property to ensure that only the top-most interactive GameObject receives input events when multiple objects overlap.
Interactive Text Hover Effects
Demonstrates how to enable input on Text Game Objects and use the gameobjectover and gameobjectout events to apply visual tint effects when hovering.
Mass Interactive Sprite Grid
A performance test featuring 10,000 interactive sprites in a grid. Demonstrates using shared hit areas for input, smoothed camera controls for navigation, and pointer events to highlight or hide objects.
Mass Scrolling Interactive Sprites
A stress test demonstrating input events and performance across 10,000 interactive sprites in a large grid, featuring camera controls and disabled camera culling.
Mass Sprite Input Detection
Demonstrates efficient pointer event handling for a large number of sprites arranged in a grid using groups and hit area callbacks.
Mouse Down Event
Detect a pointer down event and spawn a sprite at the pointer coordinates.
Mouse Wheel Input
Capture mouse wheel scroll events and use the delta values to scroll a TileSprite texture.
Mouse Wheel Over Game Object
How to detect and handle mouse wheel scroll events specifically when the cursor is positioned over an interactive Game Object.
Move Over Event
Demonstrates listening for the 'gameobjectmove' event on interactive sprites and using the 'topOnly' property to handle events for multiple overlapping objects.
Over and Out Events
Demonstrates using pointerover and pointerout events to detect when the mouse enters or leaves interactive Game Objects.
Pointer Lock
Demonstrates how to use the Pointer Lock API to capture the mouse cursor, utilizing relative mouse movement properties (movementX and movementY) to control a sprite.
Poll Only On Move
Configures input hit detection to only occur when the mouse moves. This prevents hover events from triggering automatically as moving sprites pass under a stationary cursor.
Polygon Hit Area
Define a custom interactive hit area for a Sprite using a Polygon geometry shape and the Polygon.Contains callback for precise pointer detection.
Right Mouse Button Interaction
Demonstrates how to detect right mouse button clicks, disable the default browser context menu, and use pointer duration to handle both short and long press events.
Sprite Pointer Events
Make a single sprite interactive and handle pointer down and up events to change its tint.
Top Only Input Over and Out Events
Demonstrates how to use the topOnly property to enable input events for all overlapping Game Objects simultaneously, rather than just the one on the top layer.
Triangle Hit Area
Demonstrates how to define a custom triangular hit area for a sprite using a geometric shape and a custom callback.