Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
SelfDevTV opened this issue Mar 27, 2025 · 2 comments

Comments

@SelfDevTV
Copy link

SelfDevTV commented Mar 27, 2025

wrap: function (object, padding)

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

@SelfDevTV
Copy link
Author

SelfDevTV commented Mar 27, 2025

2nd suggestion, but this is more like thinking out loudly. What about a function that wraps the objects itself, if called. Put it for examle on the gameobjects component "transform". https://docs.phaser.io/api-documentation/namespace/gameobjects-components-transform.
Like mySprite.wrap(boundsX, boundsY, paddingX, paddingY) or something like that.

Or maybe as new component / mixin similiar to https://github.com/phaserjs/phaser/blob/master/src/gameobjects/components/Flip.js

@samme
Copy link
Contributor

samme commented Mar 28, 2025

I think it would be

mySprite.wrap(left, top, right, bottom, paddingX, paddingY)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants