phaserjs / phaserjs/phaser

Misleading documentation for drop zone events

Open
#7,146 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
40.3k
Forks
7.2k
PR merge metrics
No merged PRs in 30d

Description

Version

  • Phaser Version: 3.88.2

Description

The documentation explains drop zone concept and provides examples like so:

gameObject.setInteractive({ dropZone: true });

So we instinctively think that gameObject is a drop zone. In next paragraphs the following code can be found:

gameObject.on(
  "drop",
  function (pointer, target) {
    /* ... */
  },
  scope
);

Which suggests that drop event is triggered on the zone itself. However after 1hr of experimentation I found out that it is not exactly right. The drop event is not triggered on the zone, but rather on the object that is being dragged. It would be great to rename the gameObject to something more meaningful in the documentation and provide an explicit comment on which game object the drop and other dropZone events are triggered. That way some time on debugging and experimenting can be saved for the developers. I'd propose a change in documentation via a PR but could not find the repo containing the docs.

Link: https://docs.phaser.io/phaser/concepts/input#drop-zone:~:text=gameObject.on(%0A%20%20%22drop%22%2C%0A%20%20function%20(pointer%2C%20target)%20%7B%0A%20%20%20%20/*%20...%20*/%0A%20%20%7D%2C%0A%20%20scope%0A)%3B

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the linked Phaser input documentation's drop-zone section and review the examples using gameObject.setInteractive and the drop event. Rename the example variable or otherwise distinguish the drop zone from the dragged object, and state which object receives drop-zone events; the documentation should remove the ambiguity described in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.