Source: Frontend/game/browser/ladder.mjs

  1. import LadderCommon from "../common/ladder.mjs";
  2. /*global PIXI*/
  3. /** @module Item */
  4. export default class Ladder extends LadderCommon {
  5. constructor() {
  6. super();
  7. this.sprite = new PIXI.Sprite.fromImage('DawnLike/Objects/ladder.png');
  8. this.sprite.position.set(this.x, this.y);
  9. }
  10. /**
  11. * Sets the ladder's x and y values.
  12. * @param x the x value we want to set x
  13. * @param y the y value we want to set y
  14. */
  15. setPosition(x, y) {
  16. this.x = x;
  17. this.y = y;
  18. this.sprite.position.set(this.x, this.y);
  19. }
  20. /**
  21. * Updates the sprite position
  22. * @param viewX the view x
  23. * @param viewY the view y
  24. */
  25. update(viewX, viewY) {
  26. this.sprite.position.set(this.x - viewX, this.y - viewY);
  27. }
  28. }