首页 > 文档 > pmouseX鼠标上一帧的水平位置
2017
07-14

pmouseX鼠标上一帧的水平位置

1-11.pmouseX

Name(名称):pmouseX//鼠标在当前帧之前的帧的水平位置。

Examples(例子):

// Move the mouse quickly to see the difference快速移动鼠标来看看区别

// between the current and previous position在当前和以前的位置之间

void draw() {

background(204);

line(mouseX, 20, pmouseX, 80);

println(mouseX + ” : ” + pmouseX);

}

Description(描述):The system variable pmouseX always contains the horizontal position of the mouse in the frame previous to the current frame.

系统变量pmouseX总是包含鼠标在当前帧之前的帧的水平位置。

You may find that pmouseX and pmouseY have different values when referenced inside of draw() and inside of mouse events like mousePressed() and mouseMoved(). Inside draw(), pmouseX and pmouseY update only once per frame (once per trip through the draw() loop). But inside mouse events, they update each time the event is called. If these values weren’t updated immediately during mouse events, then the mouse position would be read only once per frame, resulting in slight delays and choppy interaction. If the mouse variables were always updated multiple times per frame, then something like line(pmouseX, pmouseY, mouseX, mouseY) inside draw() would have lots of gaps, because pmouseX may have changed several times in between the calls to line().

您可能会发现,pmouseX和pmouseY在绘制()和鼠标事件(如mousePressed()和mouseMoved())中有不同的值。内绘(),pmouseX和pmouseY只更新一次每个帧(每次通过绘制()循环一次)。但是在鼠标事件中,每次调用事件时都会更新。如果这些值没有在鼠标事件中立即更新,那么鼠标的位置只会在每个帧中读取一次,从而导致轻微的延迟和颠簸的交互。如果鼠标变量总是每帧更新多次,那么在绘制()中,类似line(pmouseX,pmouseY,mouseX,mouseX,mouseY)之类的东西会有很大的差距,因为在调用line()的调用之间,pmouseX可能已经发生了好几次变化。

If you want values relative to the previous frame, use pmouseX and pmouseY inside draw(). If you want continuous response, use pmouseX and pmouseY inside the mouse event functions.

如果您想要相对于前一帧的值,则使用pmouseX和pmouseY内绘()。如果需要连续响应,可以在鼠标事件函数中使用pmouseX和pmouseY。

Related(相关函数):mouseX

mouseY
pmouseY
mousePressed
mousePressed()
mouseReleased()
mouseClicked()
mouseMoved()
mouseButton
mouseWheel()



最后编辑:
作者:卡萨布兰卡
这个作者貌似有点懒,什么都没有留下。

留下一个回复

你的email不会被公开。