Jump to content

Direction circle


jobsboris27
 Share

Recommended Posts

Hi there!

How can I sticky one ball(main ball) to another(little ball) and rotate synchronously for directional movement;

It's like a weapon for player, when weapon rotate determines the direction of movement;

function update() {
player.body.angularVelocity = 0;

  if (cursors.up.isDown) {
    game.physics.arcade.velocityFromAngle(player.angle, PLAYER_SPEED + PLAYER_ACCELERATION, player.body.velocity);
  }

  ball.anchor.setTo(1, 1);
  ball.body.x = player.body.x;
  ball.body.y = player.body.y;

  if (cursors.left.isDown) {
    ball.angle -= 0.05 * 100; //bug
    player.body.angularVelocity = -PLAYER_SPEED_ROTATE_WITH_BALL;
  } else if (cursors.right.isDown) {
    ball.angle += 0.05 * 100; //bug
    player.body.angularVelocity = PLAYER_SPEED_ROTATE_WITH_BALL;
  }
}

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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