Esempio n. 1
0
        public static CCRect CCRectApplyAffineTransform(CCRect rect, CCAffineTransform anAffineTransform)
        {
            float top    = CCRect.CCRectGetMinY(rect);
            float left   = CCRect.CCRectGetMinX(rect);
            float right  = CCRect.CCRectGetMaxX(rect);
            float bottom = CCRect.CCRectGetMaxY(rect);

            CCPoint topLeft     = CCPointApplyAffineTransform(new CCPoint(left, top), anAffineTransform);
            CCPoint topRight    = CCPointApplyAffineTransform(new CCPoint(right, top), anAffineTransform);
            CCPoint bottomLeft  = CCPointApplyAffineTransform(new CCPoint(left, bottom), anAffineTransform);
            CCPoint bottomRight = CCPointApplyAffineTransform(new CCPoint(right, bottom), anAffineTransform);

            float minX = Math.Min(Math.Min(topLeft.X, topRight.X), Math.Min(bottomLeft.X, bottomRight.X));
            float maxX = Math.Max(Math.Max(topLeft.X, topRight.X), Math.Max(bottomLeft.X, bottomRight.X));
            float minY = Math.Min(Math.Min(topLeft.Y, topRight.Y), Math.Min(bottomLeft.Y, bottomRight.Y));
            float maxY = Math.Max(Math.Max(topLeft.Y, topRight.Y), Math.Max(bottomLeft.Y, bottomRight.Y));

            return(new CCRect(minX, minY, (maxX - minX), (maxY - minY)));
        }
Esempio n. 2
0
        public virtual void keyboardWillShow(CCIMEKeyboardNotificationInfo info)
        {
            CCLog.Log("TextInputTest:keyboardWillShowAt(origin:{0:F3},{1:F3}, size:{2:F3},{3:F3})",
                      info.end.Origin.X, info.end.Origin.Y, info.end.Size.Width, info.end.Size.Height);

            if (m_pTrackNode != null)
            {
                return;
            }

            CCRect rectTracked = TextInputTestScene.getRect(m_pTrackNode);

            CCLog.Log("TextInputTest:trackingNodeAt(origin:{0:F3},{1:F3}, size:{2:F3},{3:F3})",
                      rectTracked.Origin.X, rectTracked.Origin.Y, rectTracked.Size.Width, rectTracked.Size.Height);

            // if the keyboard area doesn't intersect with the tracking node area, nothing need to do.
            if (!CCRect.CCRectIntersetsRect(rectTracked, info.end))
            {
                return;
            }

            // assume keyboard at the bottom of screen, calculate the vertical adjustment.
            float adjustVert = CCRect.CCRectGetMaxY(info.end) - CCRect.CCRectGetMinY(rectTracked);

            CCLog.Log("TextInputTest:needAdjustVerticalPosition({0:F3})", adjustVert);

            // move all the children node of KeyboardNotificationLayer
            CCNode ccnoed = new CCNode();

            var     children = ccnoed.Children;
            CCNode  node;
            int     count = children.Count;
            CCPoint pos;

            for (int i = 0; i < count; ++i)
            {
                node          = (CCNode)children[i];
                pos           = node.Position;
                pos.Y        += adjustVert;
                node.Position = pos;
            }
        }