Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Updated Legacy PhaserJS Project and finding odd behavior


Venom
 Share

Recommended Posts

Hello,

A number of years ago, I created and published a game, and for various reasons I want to resume the project and build upon it in PhaserJS again.

I rewrote all my gulp tasks, and now I have the game running; it loads the boot screen, the game select screen, I can toggle the sound on/off and the music on off and then it renders the game state; however now when it tries to render an item which I then tween, I get JS errors which must not have happened in the past, and the threads I found all date from that time, and confirm my approach is the right one, so something must have changed in the time since.

This is the failing function; it fails by saying the onComplete method does not exist - all the methods in this which use onComplete report the error.

What am I doing wrong, or what has changed? I tried using 2.9.x, but I have reverted to 2.6.x and both have the same issue.

Many thanks


 

  drawCookie: function () {
    this.logger('Game.drawCookie');

    if (!this.pausedState) {

      for (var i = 0; i < this.maxCookies; i++) {
        var cookieObject = this.game.cookies.types[this.generateCookieIndex()];
        this.cookieGroup.add(this.createCookie(cookieObject));
      }

      this.cookieGroup.forEach(function (sprite) {

        var cookieSizeTween = this.game.add.tween(sprite.scale).to({
          x: 1,
          y: 1
        }, 300, window.Phaser.Easing.Elastic.Out, true);

        var cookieTween = this.game.add.tween(sprite).to({
          alpha: 0
        }, this.game.rnd.integerInRange(this.minCookieDisplayTime, this.maxCookieDisplayTime), window.Phaser.Easing.Linear.None);

        cookieSizeTween._lastChild.onComplete.add(function () {
          cookieTween.start();
        }, this);

        if (sprite.value < 0) {
          cookieTween._lastChild.onComplete.add(function () {
            this.context.ignoredCookie(this.spriteObj);
          }, { context : this, spriteObj: sprite });
        } else {
          cookieTween._lastChild.onComplete.add(function () {
            this.context.missedCookie(this.spriteObj);
          }, { context : this, spriteObj: sprite });
        }

        sprite.events.onInputDown.add(function () {
          this.context.collectCookie(this.spriteObj, this.sTween);
        }, { context : this, spriteObj : sprite, sTween : cookieTween });

      }, this);
    }
  },

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...