截屏2026-10-07 下午9.37.20.png

I understand that the x parameter inside moveBall() can only be used within that function, so I can’t use it in drawball() to draw the ball. How can I make moveBall() and drawBall() share the same x position so the ball moves correctly?

截屏2026-10-07 下午10.16.38.png

How can I make a new ripple appear at the mouse position each time I click, while keeping the previous ripples on the screen and letting them continue to expand?

can do with array?数组 a

var ripple = {
  x: 0,
  y: 100,
  diameter: 50
};

. function 和 class 的区别

function = 做一件事

class = 定义一种东西

function drawBall(x, y) {
  circle(x, y, 50);
}

这个 function 的作用是:

在指定位置画一个球。

但如果你希望每一个球都有自己的: