Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Function inside an if else statement of update function. Phaser 3.15.1


vanni784
 Share

Recommended Posts

var config = {
    type: Phaser.AUTO,
    width: 800,
    height: 600,
    physics: {
        default: 'arcade',
        arcade: {
            gravity: { y: 400 },
            debug: false,
            setBounds: true
        }
    },
   // gravity: {y:400},
    scene: {
        preload: preload,
        create: create,
        update: update,
        collideaa: collideaa
    }
};

function create(){
---some codes here--
}

function update(time, delta)
{
if(gameoverID == false){

  if(this.boy.y > this.cameras.main.height || this.boy.y <= 0) {

            // collide();
              this.events.on(collideaa(), this);
            //collideaa();
            //this.collideaa();
}
}
}

function collideaa() 
{
    this.physics.pause();
}

my function in update doesnt work. well actually it somehow works but after it is passed to the function but it says that the pause doesnt work. When i try other methods of using the function like the code below, it apparently works properly
 

function create(){
    this.physics.add.collider(this.boy, this.pipes, collideaa, null, this);
}

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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