All Downloads are FREE. Search and download functionalities are using the official Maven repository.

view.entity-module.TilingSprite.js Maven / Gradle / Ivy

import { SpriteBasedEntity } from './SpriteBasedEntity.js'

/* global PIXI */

export class TilingSprite extends SpriteBasedEntity {
  constructor () {
    super()
    Object.assign(this.defaultState, {
      tileX: 0,
      tileY: 0,
      tileScaleX: 1,
      tileScaleY: 1
    })
  }

  initDisplay () {
    super.initDisplay()
    this.graphics = new PIXI.extras.TilingSprite(PIXI.Texture.EMPTY)
  }

  updateDisplay (state, changed, globalData) {
    super.updateDisplay(state, changed, globalData)

    this.graphics.tilePosition.x = state.tileX
    this.graphics.tilePosition.y = state.tileY
    this.graphics.tileScale.x = state.tileScaleX
    this.graphics.tileScale.y = state.tileScaleY
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy