Sign in to follow this  
vanni784

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

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);
}

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.