Jump to content

Handle diagonal car ramp


Bartuken
 Share

Recommended Posts

Greetings from a newbie in Phaser.
 

In a 2d car game, how do you imagine a car ramp?

Is there any way to draw a diagonal object and when the car object hits that start decreasing the angle and increasing the position.y?

Progress!

I started with Phaser.Physics.P2JS ( had to quit using Phaser.Physics.ARCADE ) 
Then make an sprite and assigned a Polygon:

preload(){

  this.load.physics('physicsData', '/app/dist/sprites.json');

}

create(){

  game.physics.startSystem(Phaser.Physics.P2JS);
  game.physics.p2.gravity.y = 50;
  game.physics.p2.defaultRestitution = 0.01;

  ramp = game.add.sprite(100, 100, 200, 100, "block");
  game.physics.p2.enable(ramp);
  ramp.body.clearShapes();
  ramp.body.loadPolygon('physicsData', 'ramp');

}

My sprites.json is:

{
  "ramp": [
      {
		"density": 2, "friction": 0, "bounce": 0,
		"filter": { "categoryBits": 1, "maskBits": 65535 },
		"shape": [  200, 0 , 200, 100 , 0, 100  ]
	  }
  ]
}

giphy.gif

I think I got it.

Any advice is good

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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