Jump to content

Handle diagonal car ramp

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?


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


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



  game.physics.p2.gravity.y = 50;
  game.physics.p2.defaultRestitution = 0.01;

  ramp = game.add.sprite(100, 100, 200, 100, "block");
  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  ]


I think I got it.

Any advice is good

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.

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.

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...