I am attempting to move a circle left and right. Below is the method that I tried. I get the result correct of x having the value of 600 but the circle doesn't change its position. Maybe it's related to the draw function because it's already been drawn?
Can someone help me figure out what is wrong or is there a better way of moving the object from left to right using a button click?
function Particle(x, y, r) {
this.hue = random(360);
var options = {
restitution: 0.8,
friction: 0
}
x = 300;
this.body = Bodies.circle(x, y, r, options);
this.body.label = "particle";
this.r = r;
World.add(world, this.body);
$('#moveR').click(function() {
for (i = x; i <= WIDTH; i++) {
x = i;
console.log(x);
}
});