phaserjs / phaserjs/phaser

Allow `this.physics.world.wrap` wrapping with an additional y axis padding parameter

Open
#7,088 2 comments 0 reactions 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

https://github.com/phaserjs/phaser/blob/a5a56b22e7017e3595df5f16dcd0dded3f8054a4/src/physics/arcade/World.js#L2443

When I want to wrap a sprite at the screen this way:

[.....==>]
[...........=]
[..............]
[ >.........]
[=>.......]
[==>....]

(and the same for up and down)
This is currently not possible (unless your width + height are equal).

For example to wrap as I want it to work on X I can do it like this: this.physics.world.wrap(this.test, this.test.getBounds().width / 2); But then this won't work on the Y Axis.

The solution:

A third optional parameter. Like so:
this.physics.world.wrap(gameObject, paddingX, paddingY)

gameObject = game object, group or array of game objects
paddingX = optional x padding, default 0
paddingY = optinal y padding, default paddingX

If approved I would like to contribute and try to implement it.

BR Geralt

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 in src/physics/arcade/World.js at the linked wrap implementation and read how the current padding value is applied on both axes. Verify the requested API shape: paddingY is optional, defaults to paddingX, and supports separate vertical wrapping; done means existing calls still work while unequal X and Y padding work as described.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
game-dev
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.