2 Replies - 217 Views - Last Post: 18 November 2017 - 04:27 AM Rate Topic: -----

#1 lastpeony  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 32
  • Joined: 14-October 17

Phaser creating state in same file typescript error

Posted 18 November 2017 - 01:18 AM

I am trying to create a gamestate in phaser.
The problem is typescript is not allowing me to do it by this
 Iam triying to put all functions into 1 state then call that state.

 let gameState = {
    //preload update create functions here
      
    };

After initializing game
    this.game.state.add('game', gameState);



Then call state 
this.game.state.start('gameState');


The problem is typescript doesnt let me to create a state with above let gameState structure.It says Unexpected token. A constructor, method, accessor, or property was expected.

Is This A Good Question/Topic? 0
  • +

Replies To: Phaser creating state in same file typescript error

#2 snoopy11  Icon User is online

  • Engineering ● Software
  • member icon

Reputation: 1409
  • View blog
  • Posts: 4,483
  • Joined: 20-March 10

Re: Phaser creating state in same file typescript error

Posted 18 November 2017 - 03:25 AM

It would just be like this surely..

function preload() {
   
 let gameState = this.game.state.add('game', gameState);

 this.game.state.add('game', gameState);




}



curly brackets are for functions and classes not variables
Was This Post Helpful? 0
  • +
  • -

#3 lastpeony  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 32
  • Joined: 14-October 17

Re: Phaser creating state in same file typescript error

Posted 18 November 2017 - 04:27 AM

View Postsnoopy11, on 18 November 2017 - 03:25 AM, said:

It would just be like this surely..

function preload() {
   
 let gameState = this.game.state.add('game', gameState);

 this.game.state.add('game', gameState);




}



curly brackets are for functions and classes not variables


i know this so how do i create a new state ? in examples its like let gameState={functions here };
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1