Jump to content

Uncaught TypeError: Cannot set property '6' of undefined


Glaydur
 Share

Recommended Posts

Was following codevinsky's flappy bird tutorial and this error showed up on the chrome dev tool. Here's the line that shows up when I press the error:

Object.defineProperty(Phaser.Sprite.prototype, "exists", {    get: function () {        return !!this._cache[6];    },    set: function (value) {        if (value)        {            //  exists = true            this._cache[6] = 1;            if (this.body && this.body.type === Phaser.Physics.P2JS)            {                this.body.addToWorld();            }            this.visible = true;        }        else        {            //  exists = false            this._cache[6] = 0;            if (this.body && this.body.type === Phaser.Physics.P2JS)            {                this.body.removeFromWorld();            }            this.visible = false;        }    }});

Here's the relevant part of code in the scoreboard.js prefab and says it has an error in line I highlighted. But the above error shows up first in chrome's dev tool. I don't think I made any typo or:

'use strict';var Scoreboard = function(game) {    var gameover;    Phaser.Group.call(this, game);    gameover = this.create(this.game.width / 2, 100, 'gameover');    gameover.anchor.setTo(0.5, 0.5);        this.scoreboard = this.create(this.game.width / 2, 200, 'scoreboard');    this.scoreboard.anchor.setTo(0.5, 0.5);        this.scoreText = this.game.add.bitmapText(this.scoreboard.width, 180, 'flappyfont', '', 18);    this.add(this.scoreText);        this.bestScoreText = this.game.add.bitmapText(this.scoreboard.width, 230, 'flappyfont', '', 18);    this.add(this.bextScoreText);        this.startButton = this.game.add.button(this.game.width / 2, 300, 'startButton', this.startClick, this);    this.startButton.anchor.setTo(0.5, 0.5);        this.add(this.startButton);        this.y = this.game.height;    this.x = 0;  };

I would appreciate any help. Maybe this code isn't supported in Phaser 2.1.1 anymore?

 

EDIT: So I just noticed that the colors weren't chancing for the highlighted part so I'll just post here what line the error pointed to:

 

this._cache[6] = 1;

Link to comment
Share on other sites

  • 5 months later...
 Share

  • Recently Browsing   0 members

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