質問

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!

役に立ちましたか?

解決

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);
    }
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top