Created
June 30, 2015 21:11
-
-
Save jonathanhirz/7e0bef4904c0f19d05d3 to your computer and use it in GitHub Desktop.
gesluxe zoom gesture work around
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override function onenter<T>( _value:T ) { | |
earth = new Sprite({ | |
texture : earth_texture, | |
pos : new Vector(Luxe.screen.w/2, Luxe.screen.h), | |
}); | |
transformGesture = new TransformGesture(); | |
transformGesture.events.listen(GestureEvent.GESTURE_BEGAN, onTransformGesture); | |
transformGesture.events.listen(GestureEvent.GESTURE_CHANGED, onTransformGesture); | |
transformGesture.events.listen(GestureEvent.GESTURE_ENDED, onTransformGestureEnded); | |
} //onenter | |
function onTransformGesture(event : GestureEventData) { | |
// panning view (moving camera) | |
earth.rotation_z += transformGesture.offsetX / 10; | |
earth.pos.y = Luxe.screen.h/2 - 80 + (Luxe.screen.h/2 * (Luxe.camera.zoom / maximum_zoom)); | |
// zooming | |
// trace(transformGesture.scale); | |
if(transformGesture.scale != 1) { | |
Luxe.camera.zoom = current_camera_zoom * transformGesture.scale; | |
Luxe.camera.zoom = luxe.utils.Maths.clamp(Luxe.camera.zoom, minimum_zoom, maximum_zoom); | |
trace(Luxe.camera.zoom); | |
} | |
} //onTransformGesture | |
function onTransformGestureEnded(event : GestureEventData) { | |
current_camera_zoom = Luxe.camera.zoom; | |
// trace(current_camera_zoom); | |
} //onTransformGestureEnded |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment