Jump to content

P2 Collision Problem - Bounce and N


i3Designer
 Share

Recommended Posts

Hello guys I am creating a small game , and for the first time use physics p2 , so not very good .

I created:

        this.tab = game.add.sprite(game.world.centerX,game.world.centerY,'tab',0,this.gruppo);

        this.tab.anchor.setTo(0.5);
        this.tab.scale.setTo(0.20);
        game.physics.enable(this.tab,Phaser.Physics.P2JS,true);
        this.tab.body.static = true;
        this.tab.pivot.y = -520;
        this.tab.body.clearShapes();
        this.tab.body.addRectangle(60,10,0,104);

 

and

        this.palla = game.add.sprite(game.world.centerX,game.world.centerY,'ball',0,this.gruppo);
        this.palla.anchor.setTo(0.5);
        this.palla.scale.setTo(0.25);
        game.physics.enable(this.palla,Phaser.Physics.P2JS,true);
       
        this.palla.body.clearShapes();
        this.palla.body.addCircle(8,0,0);

 

        //this.palla.body.static = true;

 

+

 

        game.physics.p2.gravity.y = 100;

        game.physics.p2.setImpactEvents(true);
        game.physics.p2.restitution=1;
       
       
        this.palla.body.onBeginContact.add(function(){
            console.log("OK");
            game.physics.p2.gravity.y = 0;
        }, this);

 

what happens?

When I start the game , the ball bounces and goes on to ( restitution 1 ) , but as soon as I move with the " tab" the ball passes through the tab.

why?

 

PS: I used 2.3.0 Version

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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