コード例 #1
0
// ----------------
    private void Update()
    {
        if (Input.GetKeyUp(KeyCode.Escape))
        {
            DemoSwipeMenuCS.LoadMenuScene();
            return;
        }

        // Manually poll and update the controller...

        this.ctrl.PollController();
        this.ctrl.UpdateController();


        // Control and update the player controller...

        if (this.player != null)
        {
            this.player.ControlByTouch(this.ctrl, this);
            this.player.UpdateChara();
        }



        // Popup box update...

        if (this.popupBox != null)
        {
            if (!this.popupBox.IsVisible())
            {
                if (Input.GetKeyDown(KeyCode.Space))
                {
                    this.popupBox.Show(INSTRUCTIONS_TITLE, INSTRUCTIONS_TEXT,
                                       INSTRUCTIONS_BUTTON_TEXT);
                }
            }
            else
            {
                if (Input.GetKeyDown(KeyCode.Space))
                {
                    this.popupBox.Hide();
                }
            }
        }



        // Control camera...

        TouchZone  zoneScreen = this.ctrl.GetZone(ZONE_SCREEN);
        TouchStick stickWalk  = this.ctrl.GetStick(STICK_WALK);



        // If screen is pressed by two fingers (excluding mid-frame press and release).

        if (zoneScreen.MultiPressed(false, true))
        {
            if (!this.isMultiTouching)
            {
                // If we just started multi-touch, store initial zoom factor.

                this.pinchStartZoom  = this.camZoom;
                this.isMultiTouching = true;

                // Cancel stick's touch if it's shared with our catch-all zone...

                zoneScreen.TakeoverTouches(stickWalk);
            }


            // If pinching is active...

            if (zoneScreen.Pinched())
            {
                // Get pinch distance delta in centimeters (screen-size independence!),
                // then add it to our non-clamped state variable...

                this.pinchStartZoom += this.zoomFactorPerCm *
                                       zoneScreen.GetPinchDistDelta(TouchCoordSys.SCREEN_CM);

                // ... and pass it to proper function when zoom factor will be clamped.

                this.SetZoom(this.pinchStartZoom);
            }
        }

        // If less than two fingers are touching the zone...
        else
        {
            this.isMultiTouching = false;
        }



        // Update camera...

        this.camZoom           = Mathf.Clamp01(this.camZoom);
        this.camZoomForDisplay = Mathf.SmoothDamp(this.camZoomForDisplay, this.camZoom,
                                                  ref this.camZoomVel, this.camSmoothingTime);



        // Place camera...

        this.PlaceCamera();
    }