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

Draw a polygon with P2 Physics


drokt
 Share

Recommended Posts

Hello everyone, i'm trying to draw a polygon with the P2 physics engine, but the only way i've found is to use the render function. How could i draw a polygon without an image, just drawing the points. (like in graphics). Sorry for the bad english.

 

 

 

 
var stageOne = {
 
    preload: function () {
 
       
        this.game.load.image('contra2', 'assets/img/lel.png');
        this.game.load.physics('data', 'assets/json/head.json');
 
        },
 
        create: function () {
            
 
            this.game.physics.startSystem(Phaser.Physics.P2JS);
            contra = this.game.add.sprite(400, 300, null);
           
 
          
            this.game.physics.p2.enable(contra, true);
 
           
            contra.body.clearShapes();
            contra.body.loadPolygon('data','300');
 
            
 
  
 
            this.graficas = this.game.add.graphics(0, 0);
 
            var personaje = new char(this.graficas,"Casiel");
 
            
        },
        update: function () {
 
        },
    
        render: function () {
 
        }
 
}
 

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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