Jump to content

scale transform velocity


nak3ddogs
 Share

Recommended Posts

helo. 

the ball.scale  scale the ball's velocity and i cant stop the ball's x movement antway.
why?

thx for any advance

    	function createGround() {		    var ball = this.add.sprite(this.menu_group.x - this.bg_popup.width/2 + this.bg_popup.width * Math.random(), this.menu_group.y + this.bg_popup.height/2 - 20, 'ground');		    this.physics.enable(ball, Phaser.Physics.ARCADE);		    scale = this.rnd.realInRange(0.2, 2);		    ball.scale.x = scale;            ball.scale.y = scale;		    ball.anchor.setTo(0.5,0.5);		    ball.angle = 360 * Math.random();        	ball.body.gravity.y = 500;        	ball.body.maxVelocity.y = 200;        	ball.body.maxVelocity.x = 0;        	ball.outOfBoundsKill = true;		    this.time.events.add(2000 * Math.random(), createGround, this);		}		this.time.events.add(1000, createGround, this);
Link to comment
Share on other sites

 

The physical body is created based on the size, angle sprite anchor - because calculated body center mass.

function createGround() {         var ball = this.add.sprite(this.menu_group.x - this.bg_popup.width/2 + this.bg_popup.width * Math.random(), this.menu_group.y + this.bg_popup.height/2 - 20, 'ground');         scale = this.rnd.realInRange(0.2, 2);         ball.scale.set(scale, scale);           ball.anchor.setTo(0.5,0.5);         ball.angle = 360 * Math.random();         this.physics.enable(ball, Phaser.Physics.ARCADE);           ball.body.gravity.y = 500;         ball.body.maxVelocity.y = 200;         ball.body.maxVelocity.x = 0;         ball.outOfBoundsKill = true;         this.time.events.add(2000 * Math.random(), createGround, this); }       

or

 

 ball.body.velocity.set(0,0); - zero the velocity
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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