Skip to content
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

Incorrect typing for Phaser.Types.GameObjects.Particles.RandomZoneSourceCallback #6784

Open
IKhonakhbeeva opened this issue Apr 8, 2024 · 1 comment

Comments

@IKhonakhbeeva
Copy link

IKhonakhbeeva commented Apr 8, 2024

Version

  • Phaser Version: 3.80.1
  • Operating system:
  • Browser:

Description

There is a typescript error when I am trying to create RandomZone for ParticlesEmitter.

Example Test Code

const emitRect = new Phaser.Geom.Rectangle()
new Phaser.GameObjects.Particles.Zones.RandomZone(emitRect)

Error:

Argument of type 'Rectangle' is not assignable to parameter of type 'RandomZoneSource'.
Types of property 'getRandomPoint' are incompatible.
Type '(point?: O | undefined) => O' is not assignable to type 'RandomZoneSourceCallback'.
Types of parameters 'point' and 'point' are incompatible.
Type 'Vector2Like' is missing the following properties from type 'Point': type, setTo

Additional Information

@zackabrah
Copy link

zackabrah commented Jun 9, 2024

Looks like the RandomZoneSourceCallback's parameter is typed as Phaser.Types.Math.Vector2Like whereas the emitRect's getRandomPoint function returns type Phaser.Geom.Point.

As a workaround you could do something like

const emitRect = new Phaser.Geom.Rectangle();
new Phaser.GameObjects.Particles.Zones.RandomZone({
  getRandomPoint: () => emitRect.getRandomPoint()
});

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

No branches or pull requests

3 participants