Jump to content

TypeError: this.onTextureUpdate is not a function


rtlehr
 Share

Recommended Posts

When trying to extend a sprite using the technique in the example below I'm getting an error (the one in the subject line)

 

 

Example I am trying to follow

 

http://examples.phaser.io/_site/view_full.html?d=sprites&f=extending+sprite+demo+1.js&t=extending%20sprite%20demo%201

 

The line that I believe is causing the problem

 

Phaser.Sprite.call(this, this.game, 0, 0, 'motherShip');

 

The sprite code

MotherShip = function(game) {    this.game = game;        Phaser.Sprite.call(this, this.game, 0, 0, 'motherShip');    this.anchor.setTo(0.5,0.5);    this.name = "motherShip";            this.speed = 3;};MotherShip.prototype = Object.create(Phaser.Sprite.prototype);MotherShip.prototype.constructor = MotherShip;MotherShip.prototype.update = function(){    this.x += this.speed;    if(this.x < 250 || this.x > (this.game.world.width - 250))    {        this.speed = this.speed * -1;    }};

The code where I am trying to create the Mothership (this lives inside of the games "play" state in the "create" function)

//Create Mothership        this.mothership = new MotherShip(this.game);        game.add.existing(this.mothership);

The code works fine if I set it up like the example I am following, but as soon as I try to set it up within a game state I get the error.  I've tried a few things and I just can't figure it out.  Thanks for any help,

 

Ross

Link to comment
Share on other sites

DAMN!!! Sorry for the waisted internet space.... turns out it was coder error.  I had all of my game objects being controled by seperate classes (I did not know I could extend the sprite class), now I am converting all the game object classes to extend the sprite class and I had missed converting some code that was breaking everything.

 

Lesson.... learn the framework!!

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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