Skip to content

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

@RyanMullins

Description

@RyanMullins

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions