starling and napephys updating hand anchor

98 Views Asked by At

I am currently using the native stage to calculate the physic bodies in nape physics world i am using, the display objects are built on starling engine.

I am wondering if this is the best way to mix starling and nape together (using native stage on enter frame) or maybe there is a better approach then:

PivotJoint(_hand).anchor1.setxy( _nativeStage.mouseX, _nativeStage.mouseY );

I have been experiencing some issues with dragging on different resolutions and some performance issues and I suspect this might be the reason.

Thanks!

1

There are 1 best solutions below

0
On BEST ANSWER

I'm not sure if it will improve performance, but you can use Starling's touch events to get the stage mouse coords.

Try something like:

private var stageCoords:Point = new Point();

stage.addEventListener(TouchEvent.TOUCH, onTouch);

private function onTouch(e:TouchEvent):void {
    var touches:Vector.<Touch> = e.getTouches(stage);
    if(touches.length > 0){
        stageCoords = touches[0].getLocation(stage);
    }
}