Any way to get a world swipe start/end position?



  • As the title says, I'm trying to check for swipes in world position in the same way i would with FlxG.mouse and FlxG.touches, but swipes seem to always be on screen

    Is there something I'm missing or should I just register clicks myself and create my own swipes?
    Thanks



  • FlxTouch seems to be missing the screenX, screenY, x, y different properties that are in the documentation

    For simplicity, is there any reason you can't just subtract the screen values from FlxG.camera.scroll?



  • I use a camera with variable zoom so I'm unsure if that'd affect it?



  • This post is deleted!


  • In case it can be helpful to someone, I solved it by basically porting over the code from FlxG.mouse.getWorldPosition() and applying it to my swipes.

    public function toWorldPosition(arg_cam:FlxCamera, arg_point:FlxPoint):FlxPoint
    {
    	var ret_point = FlxPoint.get(arg_cam.scroll.x, arg_cam.scroll.y);
    	ret_point.x += (arg_point.x - arg_cam.x + 0.5 * arg_cam.width * (arg_cam.zoom - arg_cam.initialZoom)) / arg_cam.zoom;
    	ret_point.y += (arg_point.y - arg_cam.y + 0.5 * arg_cam.height * (arg_cam.zoom - arg_cam.initialZoom)) / arg_cam.zoom;
    	return ret_point;
    }
    

    I feed this my zoomed in camera and the start and end swipe positions and works great

    I kind of feel maybe HxFlx should come with this already?


Log in to reply
 

Looks like your connection to HaxeFlixel was lost, please wait while we try to reconnect.