Jump to content

p2.createSpring - arcade version?


Recommended Posts

Hola amigos!
Is there a createSpring function with arcade physics?
I'm in development of a platformer and I want my character to have a rope-like ability. Kind of like give up robot, but first of all I need to know how to create a spring between two objects.
I've tried creating an object with p2 physics tracking the characters position. When the rope ability is called the positions is swapped. Lets just say it didn't meet the requirements (it's greasy):

	rope: function() {		if (this.cursors.up.isDown)		{			this.ropeSpring = this.game.physics.p2.createSpring(this.testP2.body, this.springBox.body, 5, 0.5, 0.5);			this.line.setTo(this.testP2.x, this.testP2.y, this.springBox.x, this.springBox.y);			this.drawLine = true;		} else {			this.game.physics.p2.removeSpring(this.ropeSpring);			this.drawLine = false;		}	},		springTest: function() {		if(!this.drawLine) {			this.testP2.body.x = this.character.body.x;			this.testP2.body.y = this.character.body.y;		} else if(this.drawLine) {				this.character.body.x = this.testP2.body.x;				this.character.body.y = this.testP2.body.y;			}	},
Link to comment
Share on other sites


  • Recently Browsing   0 members

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