Jump to content

Cannot set property 'width' of undefined


camelot10
 Share

Recommended Posts

i got this error

 

    Phaser v2.2.1 | Pixi.js v2.2.0 | WebGL | WebAudio     http://phaser.io ♥♥♥Tutorial.js:22 Phaser.SpriteTutorial.js:23 Uncaught TypeError: Cannot set property 'width' of undefinedTutorial.js:23 Phaser2048.Tutorial.createphaser.js:18686 Phaser.StateManager.loadCompletephaser.js:19383 Phaser.SignalBinding.executephaser.js:19206 Phaser.Signal.dispatchphaser.js:57772 Phaser.Loader.nextFilephaser.js:57722 Phaser.Loader.xmlLoadCompletephaser.js:57367 _xhr.onload

in this code

Phaser2048.Tutorial = function(game){this.bgSpite = null;this.bgSpiteTop = null;};Phaser2048.Tutorial.prototype = {preload: function(){this.load.image('bg-bottom', 'images/bg.png');this.load.image('bg-top', 'images/bg-top.png');this.load.image('tile00', 'images/tile00.png');this.load.image('tile01', 'images/tile01.png');this.load.image('tile02', 'images/tile02.png');this.load.image('tile03', 'images/tile03.png');this.load.bitmapFont('main-font', 'fonts/bang_whack_pow.png', 'fonts/bang_whack_pow.fnt'); },create: function(){this.bgSpite = this.game.add.sprite(0, 0, 'bg-bottom');console.log(this.bgSpite);this.bgSprite.width = 500;// ERROR <<<< HERE <<<<<this.bgSprite.height = 500;///*this.bgSpite.inputEnabled = true;this.bgSpite.events.onInputDown.addOnce(this.nextTutorialPage, this);this.bgSpiteTop = this.add.image(0, 0, 'bg-top');this.bgSpiteTop.width = this.world.width;this.bgSpiteTop.height = this.world.height;//*/},nextTutorialPage: function(pointer){console.log('next tutorial page');}};

picture is displayed, width and height not changed, console shows that sprite created but width is undefined

 

can someone tell me what im doing wrong ?

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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