• Content Count

  • Joined

  • Last visited

  1. Techassi

    [SOLVED][Error] this.add.button is not a function

    Ok thank you very much for the answer! Works very well.
  2. Techassi

    [SOLVED][Error] this.add.button is not a function

    Ok thanks, I will report back!
  3. Hello, I recently started working on a small game using Phaser 3. I started of by creating a new scene for my mainmenu with a "play" button. And there is my problem: I can't add a button to my scene. My main JS file looks like this: var dimensions = { height: window.innerHeight, width: window.innerWidth } var config = { type: Phaser.AUTO, width: dimensions.width, height: dimensions.height, scene: [Mainmenu], physics: { default: 'arcade', arcade: { gravity: {y: 200} } } }; var game = new Phaser.Game(config); My mainmenu class looks like this: class Mainmenu extends Phaser.Scene { constructor() { super({key: 'Mainmenu'}); } preload() { this.load.image('sky', 'assets/sky.jpg'); this.load.image('startBtn', 'assets/button.jpg'); } create() { console.log(this); = this.add.image(window.innerWidth / 2, window.innerHeight / 2, 'sky'); this.startBtn = this.add.button(100, 100, 'startBtn', startGame, 2, 1, 0); } } function startGame() { console.log('Game started!'); } But the console is stating that "this.add.button is not a function" at line 14. So I ask you where my error is and how can I make it work? With best regards, Techassi