setPointerCapture causes uncaught error

オープン
#7,185 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
javascript
領域
frontend

調査の方向性

まずリンクされた CodePen を実行し、pointerdown ハンドラー内の setPointerCapture 呼び出しでエラーを再現します。次に、キャプチャされたポインターがウィンドウの外に出たときの Phaser のポインター入力処理を追跡し、その後、ポインターがキャプチャされたままである間、キャプチャされていないエラーなしにドラッグが継続することを確認します。

索引モデルが issue の本文から書いたものです。

説明

⌨️ Input

Version

  • Phaser Version: v3.90.0
  • Operating system: macOS
  • Browser: *

Description

I would like to allow users to drag things around and continue the drag even if the mouse (temporarily) leaves the window. The API for this is setPointerCapture. But when I use this API, Phaser crashes with Uncaught TypeError: can't access property "x", n is null as soon as the mouse leaves the window.

Example Test Code

https://codepen.io/Amzd/pen/WbQjJEQ

The important part of the codepen is:

this.input.on('pointerdown', function(e) {
    document.querySelector("canvas").setPointerCapture(e.pointerId);
})

Additional Information

There is an alternative API called pointerLock which Phaser does support but it gives a popup "example.com has taken control of your pointer. Press Esc to take back control" while setPointerCapture does not, because it only captures until you release the mouse.

https://phaser.io/examples/v3.85.0/input/mouse/view/pointer-lock

主要言語
JavaScript
スター
40.7k
フォーク
7.2k
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

phaserjs/phaser のほかの issue

phaserjs/phaser の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。