Search in sources :

Example 1 with UIEvent

use of org.robovm.apple.uikit.UIEvent in project playn by threerings.

the class RoboTouch method toTouchEvents.

private Event.Impl[] toTouchEvents(NSSet<UITouch> touches, UIEvent event) {
    final Event.Impl[] events = new Event.Impl[touches.size()];
    int idx = 0;
    for (UITouch touch : touches) {
        CGPoint loc = touch.getLocationInView(touch.getView());
        // transform the point based on our current scale
        IPoint xloc = platform.graphics().transformTouch((float) loc.getX(), (float) loc.getY());
        // on iOS the memory address of the UITouch object is the unique id
        int id = (int) touch.getHandle();
        events[idx++] = new Event.Impl(new Events.Flags.Impl(), touch.getTimestamp() * 1000, xloc.x(), xloc.y(), id);
    }
    return events;
}
Also used : TouchImpl(playn.core.TouchImpl) Events(playn.core.Events) CGPoint(org.robovm.apple.coregraphics.CGPoint) UIEvent(org.robovm.apple.uikit.UIEvent) IPoint(pythagoras.f.IPoint) UITouch(org.robovm.apple.uikit.UITouch) IPoint(pythagoras.f.IPoint) CGPoint(org.robovm.apple.coregraphics.CGPoint)

Aggregations

CGPoint (org.robovm.apple.coregraphics.CGPoint)1 UIEvent (org.robovm.apple.uikit.UIEvent)1 UITouch (org.robovm.apple.uikit.UITouch)1 Events (playn.core.Events)1 TouchImpl (playn.core.TouchImpl)1 IPoint (pythagoras.f.IPoint)1