0
如何讓鼠標像操縱桿一樣移動。這裏是我的意思的一個例子,除了這只是向右移動,並且當鼠標完全停在右邊時。如果鼠標位於中心位置並移動到鼠標所在的位置,我想讓圓圈停止。處理遊戲杆初學者
float ballX = 0; // need to keep track of the ball's current position
float ballY = 150;
void setup() {
size(300,300); // standard size
}
void draw() {
background(200); // dull background
float speed = 2.0 * (mouseX/(width*1.0));
println("speed is " + speed); // print just to check
ballX = ballX + speed; // adjust position for current movement
fill(255,0,0);
ellipse(ballX, ballY, 20,20);
}