Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ## Sricpt to allow images to be swiped across the screen by a user on the iPhone ##//
- // New image position
- var newXPosition : float;
- // Slow swipe movement
- var speed : int = 4;
- // Default Position
- var posY : float = 0.275;
- var posZ : float = -6.87;
- //currentScreen
- static var currentScreen : String;
- //Images
- var image_1 : GameObject;
- //Smooth image flip/rotation
- var rotationSmooth : float = 10;
- function Start()
- {
- newXPosition = transform.position.x;
- }
- function Update ()
- {
- var count = Input.touchCount;
- //check for each touch
- for (var i: int = 0; i < count; i++)
- {
- var touch : Touch = Input.GetTouch(i);
- // Check if the user is swiping
- if (touch.phase == TouchPhase.Moved )
- {
- // get new position
- newXPosition += touch.deltaPosition.x * speed * Time.deltaTime;
- }
- }
- transform.position = Vector3(Mathf.Lerp(transform.position.x , newXPosition,Time.deltaTime * 1) , posY , posZ);
- if(Input.GetMouseButtonDown(0))
- {
- wantedRotation = image_1.transform.rotation * Quaternion.Euler(0, 180, 0);
- }
- image_1.transform.rotation = Quaternion.RotateTowards(image_1.transform.rotation, wantedRotation, rotationSmooth * Time.deltaTime);
- }
Add Comment
Please, Sign In to add comment