Starling multitouch rotate crash windows


#1

hello,

I attached this to a sprite. when uncomenting the rotation = rotation + deltaAngle; it works (without rotation)

regards

package utils;
import openfl.geom.Point;
import starling.display.DisplayObject;
import starling.display.Sprite;
import starling.events.Touch;
import starling.events.TouchEvent;
import starling.events.TouchPhase;
import openfl.Vector;

class TouchSheet extends Sprite{
    
    public function new(contents : DisplayObject = null) {
        super();
        addEventListener(TouchEvent.TOUCH, onTouch);
       if (contents != null) {
            contents.x = Std.int(contents.width  / -2 );
            contents.y = Std.int(contents.height / -2 );
            addChild(contents);
        }
    }
    
    private function onTouch(event : TouchEvent) : Void {
        var touches:Vector<Touch> = event.getTouches(this, TouchPhase.MOVED);
        
        if (touches.length == 1) {
            
            var delta : Point = touches[0].getMovement(parent);
            x += delta.x;
            y += delta.y;

        } else if (touches.length == 2) {
            
            var touchA : Touch = touches[0];
            var touchB : Touch = touches[1];
            var currentPosA : Point = touchA.getLocation(parent);
            var previousPosA : Point = touchA.getPreviousLocation(parent);
            var currentPosB : Point = touchB.getLocation(parent);
            var previousPosB : Point = touchB.getPreviousLocation(parent);
            var currentVector : Point = currentPosA.subtract(currentPosB);
            var previousVector : Point = previousPosA.subtract(previousPosB);
            var currentAngle : Float = Math.atan2(currentVector.y, currentVector.x);
            var previousAngle : Float = Math.atan2(previousVector.y, previousVector.x);
            var deltaAngle : Float = currentAngle - previousAngle;
            var previousLocalA : Point = touchA.getPreviousLocation(this);
            var previousLocalB : Point = touchB.getPreviousLocation(this);
            pivotX = (previousLocalA.x + previousLocalB.x) * 0.5;
            pivotY = (previousLocalA.y + previousLocalB.y) * 0.5;
            x = (currentPosA.x + currentPosB.x) * 0.5;
            y = (currentPosA.y + currentPosB.y) * 0.5;

           rotation = rotation + deltaAngle;
     
        }
        event.stopImmediatePropagation();
    }
    
    override public function dispose() : Void {
        trace ("dispose touchsheet");
        removeEventListener(TouchEvent.TOUCH, onTouch);
        super.dispose();
    }
}

#2

Strange!

I used your version to replace the TouchSheet class in the Starling demo, and ran in Neko and Windows, and the multi-touch portion of the demo was fine without crashes.

Are you using the latest OpenFL and Lime?


#3

yes, I updated with haxelib update, (8.8.0…) the crash occurs on a 4k app.


#4

What platform are you targeting? Does it crash when using with the Starling demo?


#5

plattform: windows, the demo is fine.
how can I debug? the app crash when I comment out the rotation.


#6

Perhaps the issue is that rotation is not initialized? Does setting rotation = 0 somewhere help?


#7

the rotated sprite is masked, without the mask it works. I have started an issue in the github a few weeks ago.