本文整理匯總了Java中processing.core.PConstants.LEFT屬性的典型用法代碼示例。如果您正苦於以下問題:Java PConstants.LEFT屬性的具體用法?Java PConstants.LEFT怎麽用?Java PConstants.LEFT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類processing.core.PConstants
的用法示例。
在下文中一共展示了PConstants.LEFT屬性的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: click
public boolean click(String taste){
if(pressed){
if(main.mouseButton == PConstants.LEFT && taste == "links") {
return true;
}
if(main.mouseButton == PConstants.RIGHT && taste == "rechts") {
return true;
}
}
return false;
}
示例2: gameOverScreen
void gameOverScreen() {
main.image(gameOverBild, 0, 0);
main.keyPressed();
main.mouseClicked();
if(main.keyPressed || main.mousePressed); {
if(main.keyCode == PConstants.ENTER || main.mouseButton == PConstants.LEFT) {
main.SpielActive = false;
eintrag = 1;
main.delay(600);
}
}
main.mouseButton = 0;
main.keyCode = 0;
}
示例3: mouseEvent
public void mouseEvent(MouseEvent event) {
int action = event.getAction();
// mouseX = event.getX();
// mouseY = event.getY();
// if ((action == MouseEvent.DRAG) || (action == MouseEvent.MOVE)) {
// pmouseX = emouseX;
// pmouseY = emouseY;
// mouseX = event.getX();
// mouseY = event.getY();
// }
if (event.getButton() == PConstants.LEFT) {
switch (action) {
case MouseEvent.CLICK:
mouseClicked();
for (Control control : controls) {
control.update();
}
break;
case MouseEvent.DRAG:
mouseDragged();
break;
case MouseEvent.MOVE:
mouseMoved();
break;
default:
break;
}
}
if ((action == MouseEvent.DRAG) || (action == MouseEvent.MOVE)) {
emouseX = mouseX;
emouseY = mouseY;
}
}
示例4: mouseEvent
public void mouseEvent(final MouseEvent e) {
if (resetOnDoubleClick && e.getID() == MouseEvent.MOUSE_CLICKED
&& e.getClickCount() == 2) {
reset();
} else if (e.getID() == MouseEvent.MOUSE_RELEASED) {
dragConstraint = null;
} else if (e.getID() == MouseEvent.MOUSE_DRAGGED) {
final double dx = p.mouseX - p.pmouseX;
final double dy = p.mouseY - p.pmouseY;
if (e.isShiftDown()) {
if (dragConstraint == null && Math.abs(dx - dy) > 1) {
dragConstraint = Math.abs(dx) > Math.abs(dy) ? Constraint.X
: Constraint.Y;
}
} else {
dragConstraint = null;
}
final int b = p.mouseButton;
if (centerDragHandler != null
&& (b == PConstants.CENTER || (b == PConstants.LEFT && e
.isMetaDown()))) {
centerDragHandler.handleDrag(dx, dy);
} else if (leftDragHandler != null && b == PConstants.LEFT) {
leftDragHandler.handleDrag(dx, dy);
} else if (rightDraghandler != null && b == PConstants.RIGHT) {
rightDraghandler.handleDrag(dx, dy);
}
}
}
示例5: mouseEvent
public void mouseEvent(final MouseEvent e) {
if (resetOnDoubleClick && e.getID() == MouseEvent.MOUSE_CLICKED
&& e.getClickCount() == 2) {
reset();
} else if (e.getID() == MouseEvent.MOUSE_RELEASED) {
dragConstraint = null;
} else if (e.getID() == MouseEvent.MOUSE_DRAGGED) {
final double dx = p.mouseX - p.pmouseX;
final double dy = p.mouseY - p.pmouseY;
if (e.isShiftDown()) {
if (dragConstraint == null && Math.abs(dx - dy) > 1) {
dragConstraint = Math.abs(dx) > Math.abs(dy) ? Constraint.YAW
: Constraint.PITCH;
}
} else if (permaConstraint != null) {
dragConstraint = permaConstraint;
} else {
dragConstraint = null;
}
final int b = p.mouseButton;
if (centerDragHandler != null
&& (b == PConstants.CENTER || (b == PConstants.LEFT && e
.isMetaDown()))) {
centerDragHandler.handleDrag(dx, dy);
} else if (leftDragHandler != null && b == PConstants.LEFT) {
leftDragHandler.handleDrag(dx, dy);
} else if (rightDraghandler != null && b == PConstants.RIGHT) {
rightDraghandler.handleDrag(dx, dy);
}
}
}
示例6: nativeMouseEvent
protected void nativeMouseEvent(com.jogamp.newt.event.MouseEvent nativeEvent,
int peAction) {
int modifiers = nativeEvent.getModifiers();
int peModifiers = modifiers &
(InputEvent.SHIFT_MASK |
InputEvent.CTRL_MASK |
InputEvent.META_MASK |
InputEvent.ALT_MASK);
int peButton = 0;
if ((modifiers & InputEvent.BUTTON1_MASK) != 0) {
peButton = PConstants.LEFT;
} else if ((modifiers & InputEvent.BUTTON2_MASK) != 0) {
peButton = PConstants.CENTER;
} else if ((modifiers & InputEvent.BUTTON3_MASK) != 0) {
peButton = PConstants.RIGHT;
}
if (PApplet.platform == PConstants.MACOSX) {
//if (nativeEvent.isPopupTrigger()) {
if ((modifiers & InputEvent.CTRL_MASK) != 0) {
peButton = PConstants.RIGHT;
}
}
int peCount = 0;
if (peAction == MouseEvent.WHEEL) {
peCount = nativeEvent.isShiftDown() ? (int)nativeEvent.getRotation()[0] :
(int)nativeEvent.getRotation()[1];
} else {
peCount = nativeEvent.getClickCount();
}
MouseEvent me = new MouseEvent(nativeEvent, nativeEvent.getWhen(),
peAction, peModifiers,
nativeEvent.getX(), nativeEvent.getY(),
peButton,
peCount);
pg.parent.postEvent(me);
}
示例7: mouseEvent
public void mouseEvent(final MouseEvent e) {
switch (e.getAction()) {
case MouseEvent.WHEEL:
wheelHandler.handleWheel((int)e.getCount());
break;
case MouseEvent.RELEASE:
dragConstraint = null;
break;
case MouseEvent.CLICK:
if (resetOnDoubleClick && 2 == (int)e.getCount()) {
reset();
}
break;
case MouseEvent.DRAG:
final double dx = p.mouseX - p.pmouseX;
final double dy = p.mouseY - p.pmouseY;
if (e.isShiftDown()) {
if (dragConstraint == null && Math.abs(dx - dy) > 1) {
dragConstraint = Math.abs(dx) > Math.abs(dy) ? Constraint.YAW
: Constraint.PITCH;
}
} else if (permaConstraint != null) {
dragConstraint = permaConstraint;
} else {
dragConstraint = null;
}
final int b = p.mouseButton;
if (centerDragHandler != null
&& (b == PConstants.CENTER || (b == PConstants.LEFT && e
.isMetaDown()))) {
centerDragHandler.handleDrag(dx, dy);
} else if (leftDragHandler != null && b == PConstants.LEFT) {
leftDragHandler.handleDrag(dx, dy);
} else if (rightDraghandler != null && b == PConstants.RIGHT) {
rightDraghandler.handleDrag(dx, dy);
}
break;
}
}
示例8: mouseEvent
public void mouseEvent(processing.event.MouseEvent event) {
switch (event.getAction()) {
case MouseEvent.DRAG:
//Calc distance dragged
float dx = prevX - event.getX();
float dy = prevY - event.getY();
if (_parent.mouseButton == PConstants.LEFT
&& !event.isControlDown()) {
//Rotation about the z-axis, on the graph not world axis.
PVector relX = VectorUtils.rotateArbitaryAxis(getRelativePosition(),
new PVector(0, 1, 0), -dx * PConstants.PI / 100);
_position = PVector.add(relX, _lookat);
float dAngle = dy * PConstants.PI / 100;
PVector r = getRelativePosition();
//The next sections is slightly tricky, to get a better understanding
//render the vector A in the draw routine below, this shows the axis
//the camera is rotated about.
//now need to get an axis to rotate about that will allow
//the camera to orbit over the top and bottom of lookat point
A = new PVector(0, 0, 1);
//now we get the angle between the z axis and the r vector projected
//into the x-z plane only so no y comp and add 90deg
float angle = (float) Math.atan2(r.x, r.z) + PConstants.PI / 2;
//now rotate the axis A so it is orthogonal to r
A = VectorUtils.rotateArbitaryAxis(A, new PVector(0, 1, 0), angle);
//As we now have an axis that is always orthogonal to our relative
//position going through the lookat point, we rotate the camera
//position around it.
PVector relY = VectorUtils.rotateArbitaryAxis(r, A, dAngle);
//Strange things happen when the new relative position gets to 0,0,0 and flips
//to the other side, the scene flips the z and x axis(comment out this check
//to see) so basically we dont want to apply any changes if the sign has changed
if (Math.signum(r.x) == Math.signum(relY.x)
&& Math.signum(r.z) == Math.signum(relY.z)) {
_position = PVector.add(relY, _lookat);
}
}
if (_parent.mouseButton == PConstants.RIGHT
|| (_parent.mouseButton == PConstants.LEFT && event.isControlDown())) {
PVector newPos = PVector.add(_position, PVector.mult(getEyeVector(), dy * 20));
PVector relPos = PVector.sub(newPos, _lookat);
if (relPos.mag() < _nearLimit || relPos.mag() > _farLimit) {
newPos = _position;
}
_position = newPos;
}
prevX = event.getX();
prevY = event.getY();
break;
case MouseEvent.MOVE:
//Keep track of previous mouse pos
//so a distance dragged can be calculated
prevX = event.getX();
prevY = event.getY();
break;
}
}
示例9: keyReleased
public boolean keyReleased(){
if(focused){
if(canvas.key == PConstants.CODED){
if(canvas.keyCode == PConstants.RIGHT){
cursorPosition = Math.min(cursorPosition+1, value.length());
}else if(canvas.keyCode == PConstants.LEFT){
cursorPosition = Math.max(cursorPosition-1, 0);
}
}else if(canvas.keyCode == PConstants.BACKSPACE){
if(cursorPosition > cursorStart){
value = value.substring(0, cursorStart) + value.substring(cursorPosition);
cursorPosition = cursorStart;
}else if(cursorPosition < cursorStart){
value = value.substring(0, cursorPosition) + value.substring(cursorStart);
cursorStart = cursorPosition;
}else if(cursorPosition > 0){
value = value.substring(0, cursorPosition - 1) + value.substring(cursorPosition);
cursorPosition--;
cursorStart--;
}
}else if(canvas.keyCode == PConstants.DELETE){
if(cursorPosition > cursorStart){
value = value.substring(0, cursorStart) + value.substring(cursorPosition);
cursorPosition = cursorStart;
}else if(cursorPosition < cursorStart){
value = value.substring(0, cursorPosition) + value.substring(cursorStart);
cursorStart = cursorPosition;
}else if(cursorPosition < value.length()){
value = value.substring(0, cursorPosition) + value.substring(cursorPosition + 1);
}
}else if(canvas.keyCode == PConstants.ENTER){
focused = false;
events.change(this);
}else{
value = value.substring(0, cursorPosition) + canvas.key + value.substring(cursorPosition);
cursorPosition++;
cursorStart++;
}
return true;
}
return false;
}