List of mouse events for GameObjects (Phaser3)

この記事は約5分で読めます。
スポンサーリンク

Things I want to do

We’ll use Phaser3 to consolidate mouse events for GameObjects.

How to participate in an event

First, allow mouse interaction with the game object.

GameObject.setInteractive();

The following options are required when dragging:

GameObject.setInteractive({ draggable: true });

The following processing is linked during the event:

GameObject.on(イベント名, function));

example:

        const rect = this.add.rectangle(400, 300, 100, 100, 0xff0000);
        rect.setInteractive();
        rect.on('pointerdown', () => alert("clicked")); //追加
スポンサーリンク

Event List

Event NameCallback arguments詳細
load-bearingDrag completepointer, dragX, dragYhttps://newdocs.phaser.io/docs/3.80.0/Phaser.Input.Events.GAMEOBJECT_DRAG_END
carrierMove over the target while dragging.pointer, targethttps://newdocs.phaser.io/docs/3.80.0/Phaser.Input.Events.GAMEOBJECT_DRAG_ENTER
dragDruggingpointer, dragX, dragYhttps://newdocs.phaser.io/docs/3.80.0/Phaser.Input.Events.GAMEOBJECT_DRAG
dragleaveMove from above the target while dragging.pointer, targethttps://newdocs.phaser.io/docs/3.80.0/Phaser.Input.Events.GAMEOBJECT_DRAG_LEAVE
dragover
Move over the target while dragging
pointer, targethttps://newdocs.phaser.io/docs/3.80.0/Phaser.Input.Events.GAMEOBJECT_DRAG_OVER
drag startStart draggingpointer, dragX, dragYhttps://newdocs.phaser.io/docs/3.80.0/Phaser.Input.Events.GAMEOBJECT_DRAG_START
dropDrop onto targetpointer, targethttps://newdocs.phaser.io/docs/3.80.0/Phaser.Input.Events.GAMEOBJECT_DROP
pointerdownClick downpointer, localX, localY, eventhttps://newdocs.phaser.io/docs/3.80.0/Phaser.Input.Events.GAMEOBJECT_POINTER_DOWN
pointermovePointer movementpointer, localX, localY, eventhttps://newdocs.phaser.io/docs/3.80.0/Phaser.Input.Events.GAMEOBJECT_POINTER_MOVE
pointeroutThe pointer moves outside the GameObject.pointer, eventhttps://newdocs.phaser.io/docs/3.80.0/Phaser.Input.Events.GAMEOBJECT_POINTER_OUT
pointeroverPointer movementpointer, localX, localY, eventhttps://newdocs.phaser.io/docs/3.80.0/Phaser.Input.Events.GAMEOBJECT_POINTER_OVER
pointerupClick Uppointer, localX, localY, eventhttps://newdocs.phaser.io/docs/3.80.0/Phaser.Input.Events.GAMEOBJECT_POINTER_UP
wheelWheel operationpointer, deltaX, deltaY, deltaZ, eventhttps://newdocs.phaser.io/docs/3.80.0/Phaser.Input.Events.GAMEOBJECT_POINTER_WHEEL
スポンサーリンク

Websites I used as references

Redirecting to https://docs.phaser.io

コメント

タイトルとURLをコピーしました