Hi,
I just started learning Phaser 3 and I am trying to drag a ball object with the mouse to hit another ball using the velocity of the mouse. But when I drag the first Ball, the physics body’s velocity doesn’t change, and the second ball doesn’t move.
If anyone can help, I would really appreciate it.
Thank you all.
This the code I am using:
function create ()
{
var ball1 = this.physics.add.image(100, 240, ‘ball’);
var ball2 = this.physics.add.image(700, 240, ‘ball’);ball1.setCircle(46); ball2.setCircle(46); ball1.setCollideWorldBounds(true); ball2.setCollideWorldBounds(true); ball1.setBounce(1); ball2.setBounce(1); this.input.setDraggable(ball1.setInteractive()); this.input.on('dragstart', function (pointer, obj) { obj.body.moves = true; }); this.input.on('drag', function (pointer, obj, dragX, dragY) { obj.setPosition(dragX, dragY); }); this.input.on('dragend', function (pointer, obj) { obj.body.moves = true; }); this.physics.add.collider(ball1, ball2);
}