Java Code Examples for com.jme3.input.event.TouchEvent#setScaleFactor()

The following examples show how to use com.jme3.input.event.TouchEvent#setScaleFactor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AndroidGestureProcessor.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
    public boolean onScaleBegin(ScaleGestureDetector scaleGestureDetector) {
        // Scale uses a focusX and focusY instead of x and y.  Focus is the middle
        // of the fingers.  Therefore, use the x and y values from the Down event
        // so that the x and y values don't jump to the middle position.
        // return true or all gestures for this beginning event will be discarded
//        logger.log(Level.INFO, "onScaleBegin");
        scaleStartX = gestureDownX;
        scaleStartY = gestureDownY;
        TouchEvent touchEvent = touchInput.getFreeTouchEvent();
        touchEvent.set(TouchEvent.Type.SCALE_START, scaleStartX, scaleStartY, 0f, 0f);
        touchEvent.setPointerId(0);
        touchEvent.setTime(scaleGestureDetector.getEventTime());
        touchEvent.setScaleSpan(scaleGestureDetector.getCurrentSpan());
        touchEvent.setDeltaScaleSpan(0f);
        touchEvent.setScaleFactor(scaleGestureDetector.getScaleFactor());
        touchEvent.setScaleSpanInProgress(touchInput.getScaleDetector().isInProgress());
        touchInput.addEvent(touchEvent);

        return true;
    }
 
Example 2
Source File: AndroidGestureProcessor.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
    public boolean onScale(ScaleGestureDetector scaleGestureDetector) {
        // return true or all gestures for this event will be accumulated
//        logger.log(Level.INFO, "onScale");
        scaleStartX = gestureDownX;
        scaleStartY = gestureDownY;
        TouchEvent touchEvent = touchInput.getFreeTouchEvent();
        touchEvent.set(TouchEvent.Type.SCALE_MOVE, scaleStartX, scaleStartY, 0f, 0f);
        touchEvent.setPointerId(0);
        touchEvent.setTime(scaleGestureDetector.getEventTime());
        touchEvent.setScaleSpan(scaleGestureDetector.getCurrentSpan());
        touchEvent.setDeltaScaleSpan(scaleGestureDetector.getCurrentSpan() - scaleGestureDetector.getPreviousSpan());
        touchEvent.setScaleFactor(scaleGestureDetector.getScaleFactor());
        touchEvent.setScaleSpanInProgress(touchInput.getScaleDetector().isInProgress());
        touchInput.addEvent(touchEvent);
        return true;
    }
 
Example 3
Source File: AndroidGestureProcessor.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
    public void onScaleEnd(ScaleGestureDetector scaleGestureDetector) {
//        logger.log(Level.INFO, "onScaleEnd");
        scaleStartX = gestureDownX;
        scaleStartY = gestureDownY;
        TouchEvent touchEvent = touchInput.getFreeTouchEvent();
        touchEvent.set(TouchEvent.Type.SCALE_END, scaleStartX, scaleStartY, 0f, 0f);
        touchEvent.setPointerId(0);
        touchEvent.setTime(scaleGestureDetector.getEventTime());
        touchEvent.setScaleSpan(scaleGestureDetector.getCurrentSpan());
        touchEvent.setDeltaScaleSpan(scaleGestureDetector.getCurrentSpan() - scaleGestureDetector.getPreviousSpan());
        touchEvent.setScaleFactor(scaleGestureDetector.getScaleFactor());
        touchEvent.setScaleSpanInProgress(touchInput.getScaleDetector().isInProgress());
        touchInput.addEvent(touchEvent);
    }
 
Example 4
Source File: AndroidInput.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public boolean onScaleBegin(ScaleGestureDetector scaleGestureDetector)
{     
    TouchEvent touch = getNextFreeTouchEvent(); 
    touch.set(Type.SCALE_START, scaleGestureDetector.getFocusX(), scaleGestureDetector.getFocusY(), 0f, 0f);
    touch.setPointerId(0);
    touch.setTime(scaleGestureDetector.getEventTime());
    touch.setScaleSpan(scaleGestureDetector.getCurrentSpan()); 
    touch.setScaleFactor(scaleGestureDetector.getScaleFactor());
    processEvent(touch); 
    
    return true;
}
 
Example 5
Source File: AndroidInput.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public boolean onScale(ScaleGestureDetector scaleGestureDetector)
{        
    TouchEvent touch = getNextFreeTouchEvent(); 
    touch.set(Type.SCALE_MOVE, scaleGestureDetector.getFocusX(), this.getHeight() - scaleGestureDetector.getFocusY(), 0f, 0f);
    touch.setPointerId(0);
    touch.setTime(scaleGestureDetector.getEventTime());
    touch.setScaleSpan(scaleGestureDetector.getCurrentSpan()); 
    touch.setScaleFactor(scaleGestureDetector.getScaleFactor());
    processEvent(touch); 
         
    return false;
}
 
Example 6
Source File: AndroidInput.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void onScaleEnd(ScaleGestureDetector scaleGestureDetector)
{        
    TouchEvent touch = getNextFreeTouchEvent(); 
    touch.set(Type.SCALE_END, scaleGestureDetector.getFocusX(), this.getHeight() - scaleGestureDetector.getFocusY(), 0f, 0f);
    touch.setPointerId(0);
    touch.setTime(scaleGestureDetector.getEventTime());
    touch.setScaleSpan(scaleGestureDetector.getCurrentSpan()); 
    touch.setScaleFactor(scaleGestureDetector.getScaleFactor());
    processEvent(touch);      
}