Beispiel #1
0
 // ----------------------------------------------------------------------------------------------------
 // Constructor allows keeping member variables private and have only a get in the properties
 // ----------------------------------------------------------------------------------------------------
 public iPhoneTouchSim(Vector2 _deltaPosition, Vector2 _position, iPhoneTouchSim.FingerId _fingerId, iPhoneTouchPhaseSim.Phase _phase)
 {
     m_DeltaPosition = _deltaPosition;
     m_Position      = _position;
     m_FingerId      = _fingerId;
     m_Phase         = _phase;
 }
Beispiel #2
0
    // ----------------------------------------------------------------------------------------------------
    // Returns an array of iPhoneTouchSim representing all touches that are currently active
    // ----------------------------------------------------------------------------------------------------
    private static void UpdateTouches()
    {
        // Put the touches in an array to have same code behavior as on iPhone
        m_TouchCount = 0;
        if (Input.GetMouseButton(0) || Input.GetMouseButtonUp(0))
        {
            m_Touches[m_TouchCount]   = new iPhoneTouchSim(GetDeltaPosition(m_TouchCount, Input.mousePosition), Input.mousePosition, iPhoneTouchSim.FingerId.Mouse, MouseUtility.GetMousePhase());
            MouseUtility.LastPosition = m_Touches[m_TouchCount].position;
            m_TouchCount++;
        }

        // Also move the jump button to the suggested position so it does not interact with other control setups
        if (KeyboardUtility.KeyboardTouched())
        {
            m_Touches[m_TouchCount]      = new iPhoneTouchSim(GetDeltaPosition(m_TouchCount, KeyboardUtility.Position), KeyboardUtility.Position, iPhoneTouchSim.FingerId.Arrows, KeyboardUtility.GetKeyboardPhase());
            KeyboardUtility.LastPosition = m_Touches[m_TouchCount].position;
            m_TouchCount++;
        }

        // On the iPhone, taps are ordered
        if (Input.GetMouseButtonDown(0))
        {
            m_LastPcFingerId = iPhoneTouchSim.FingerId.Mouse;
        }
        else if (KeyboardUtility.KeyboardJustPressed())
        {
            m_LastPcFingerId = iPhoneTouchSim.FingerId.Arrows;
        }

        // Swap mouse & keyboard if mouse is last
        if (m_TouchCount == 2 && m_LastPcFingerId == iPhoneTouchSim.FingerId.Mouse)
        {
            iPhoneTouchSim touch = m_Touches[0];
            m_Touches[0] = m_Touches[1];
            m_Touches[1] = touch;
        }
    }