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

Convenience setters for Scene.scale and Scene.offset #86

Open
RyanMullins opened this issue Nov 7, 2022 · 0 comments
Open

Convenience setters for Scene.scale and Scene.offset #86

RyanMullins opened this issue Nov 7, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@RyanMullins
Copy link
Member

The SpriteView implementation provides convenient setters for the PositionWorld etc. properties as:

set PositionWorld(value: (number[] | {x?: number; y?: number;})) { /* ...some logic... */ }

I would like the same convenience setters for Scene.scale and Scene.offset as follows.

set scale(value: (number | number[] | {x?: number; y?: number;})) {
  if (typeof value === 'number') {
    this.scale.x = this.scale.y = value;
  } else if (Array.isArray(value)) {
    // setter logic similar to SpriteView
  } else if (typeof value === 'object') {
    // setter logic similar to SpriteView
  } else {
    throw new TypeError('Argument must be a number, number array, or object.');
  }
}

It seems like this isn't happening now because Scene.scale and Scene.offset are instances of DrawTriggerPoint, but it shouldn't be hard to move these to an internal private variable and convert the public interfaces to getters and setters. What might be more difficult to overcome is the philosophical desire to always be setting the x and y components of a DrawTriggerPoint directly.

@jimbojw jimbojw added the enhancement New feature or request label Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants