Esempio n. 1
0
        public override void StartWithTarget(CCNode target)
        {
            base.StartWithTarget(target);

            float r, zenith, azimuth;

            SphericalRadius(out r, out zenith, out azimuth);

            if (float.IsNaN(m_fRadius))
            {
                m_fRadius = r;
            }

            if (float.IsNaN(m_fAngleZ))
            {
                m_fAngleZ = CCMacros.CCRadiansToDegrees(zenith);
            }

            if (float.IsNaN(m_fAngleX))
            {
                m_fAngleX = CCMacros.CCRadiansToDegrees(azimuth);
            }

            m_fRadZ = CCMacros.CCDegreesToRadians(m_fAngleZ);
            m_fRadX = CCMacros.CCDegreesToRadians(m_fAngleX);
        }
        protected void UpdateSliderPosition(CCPoint location)
        {
            // Clamp the position of the icon within the circle
            CCRect backgroundBox = _background.BoundingBox;

            // Get the center point of the background image
            float centerX = _startPos.X + backgroundBox.Size.Width * 0.5f;
            float centerY = _startPos.Y + backgroundBox.Size.Height * 0.5f;

            // Work out the distance difference between the location and center
            float dx = location.X - centerX;
            float dy = location.Y - centerY;

            // Update angle by using the direction of the location
            var   angle    = (float)Math.Atan2(dy, dx);
            float angleDeg = CCMacros.CCRadiansToDegrees(angle) + 180.0f;

            // use the position / slider width to determin the percentage the dragger is at
            Hue = angleDeg;

            // send Control callback
            SendActionsForControlEvents(CCControlEvent.ValueChanged);
        }