当前位置: 首页>>代码示例>>C#>>正文


C# CCRect.Equals方法代码示例

本文整理汇总了C#中Cocos2D.CCRect.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# CCRect.Equals方法的具体用法?C# CCRect.Equals怎么用?C# CCRect.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cocos2D.CCRect的用法示例。


在下文中一共展示了CCRect.Equals方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InitWithTarget

        private bool InitWithTarget(CCNode pFollowedNode, CCRect rect)
        {
            Debug.Assert(pFollowedNode != null);

            m_pobFollowedNode = pFollowedNode;
            if (rect.Equals(CCRect.Zero))
            {
                m_bBoundarySet = false;
            }
            else
            {
                m_bBoundarySet = true;
            }

            m_bBoundaryFullyCovered = false;

            CCSize winSize = CCDirector.SharedDirector.WinSize;
            m_obFullScreenSize = (CCPoint)winSize;
            m_obHalfScreenSize = m_obFullScreenSize * 0.5f;

            if (m_bBoundarySet)
            {
                m_fLeftBoundary = -((rect.Origin.X + rect.Size.Width) - m_obFullScreenSize.X);
                m_fRightBoundary = -rect.Origin.X;
                m_fTopBoundary = -rect.Origin.Y;
                m_fBottomBoundary = -((rect.Origin.Y + rect.Size.Height) - m_obFullScreenSize.Y);

                if (m_fRightBoundary < m_fLeftBoundary)
                {
                    // screen width is larger than world's boundary width
                    //set both in the middle of the world
                    m_fRightBoundary = m_fLeftBoundary = (m_fLeftBoundary + m_fRightBoundary) / 2;
                }
                if (m_fTopBoundary < m_fBottomBoundary)
                {
                    // screen width is larger than world's boundary width
                    //set both in the middle of the world
                    m_fTopBoundary = m_fBottomBoundary = (m_fTopBoundary + m_fBottomBoundary) / 2;
                }

                if ((m_fTopBoundary == m_fBottomBoundary) && (m_fLeftBoundary == m_fRightBoundary))
                {
                    m_bBoundaryFullyCovered = true;
                }
            }

            return true;
        }
开发者ID:pekayatt,项目名称:cocos2d-xna,代码行数:48,代码来源:CCFollow.cs

示例2: UpdateWithBatchNode

        public bool UpdateWithBatchNode(CCSpriteBatchNode batchnode, CCRect rect, bool rotated, CCRect capInsets)
        {
            var opacity = Opacity;
            var color = Color;

            // Release old sprites
            RemoveAllChildrenWithCleanup(true);

            _scale9Image = batchnode;
            _scale9Image.RemoveAllChildrenWithCleanup(true);

            _capInsets = capInsets;
            _spriteFrameRotated = rotated;

            // If there is no given rect
            if (rect.Equals(CCRect.Zero))
            {
                // Get the texture size as original
                CCSize textureSize = _scale9Image.TextureAtlas.Texture.ContentSize;

                rect = new CCRect(0, 0, textureSize.Width, textureSize.Height);
            }

            // Set the given rect's size as original size
            _spriteRect = rect;
            _originalSize = rect.Size;
            _preferredSize = _originalSize;
            _capInsetsInternal = capInsets;

            float h = rect.Size.Height;
            float w = rect.Size.Width;

            // If there is no specified center region
            if (_capInsetsInternal.Equals(CCRect.Zero))
            {
                _capInsetsInternal = new CCRect(w / 3, h / 3, w / 3, h / 3);
            }

            float left_w = _capInsetsInternal.Origin.X;
            float center_w = _capInsetsInternal.Size.Width;
            float right_w = rect.Size.Width - (left_w + center_w);

            float top_h = _capInsetsInternal.Origin.Y;
            float center_h = _capInsetsInternal.Size.Height;
            float bottom_h = rect.Size.Height - (top_h + center_h);

            // calculate rects

            // ... top row
            float x = 0.0f;
            float y = 0.0f;

            // top left
            CCRect lefttopbounds = new CCRect(x, y,
                                              left_w, top_h);

            // top center
            x += left_w;
            CCRect centertopbounds = new CCRect(x, y,
                                                center_w, top_h);

            // top right
            x += center_w;
            CCRect righttopbounds = new CCRect(x, y,
                                               right_w, top_h);

            // ... center row
            x = 0.0f;
            y = 0.0f;
            y += top_h;

            // center left
            CCRect leftcenterbounds = new CCRect(x, y,
                                                 left_w, center_h);

            // center center
            x += left_w;
            CCRect centerbounds = new CCRect(x, y,
                                             center_w, center_h);

            // center right
            x += center_w;
            CCRect rightcenterbounds = new CCRect(x, y,
                                                  right_w, center_h);

            // ... bottom row
            x = 0.0f;
            y = 0.0f;
            y += top_h;
            y += center_h;

            // bottom left
            CCRect leftbottombounds = new CCRect(x, y,
                                                 left_w, bottom_h);

            // bottom center
            x += left_w;
            CCRect centerbottombounds = new CCRect(x, y,
                                                   center_w, bottom_h);

//.........这里部分代码省略.........
开发者ID:liwq-net,项目名称:UIFactory,代码行数:101,代码来源:CCScale9Sprite.cs

示例3: UpdateWithBatchNode

        public bool UpdateWithBatchNode(CCSpriteBatchNode batchnode, CCRect rect, bool rotated, CCRect capInsets)
        {
            byte opacity = m_cOpacity;
            CCColor3B color = m_tColor;

            // Release old sprites
            RemoveAllChildrenWithCleanup(true);

            if (scale9Image != batchnode)
            {
                scale9Image = batchnode;
            }

            scale9Image.RemoveAllChildrenWithCleanup(true);

            m_capInsets = capInsets;

            // If there is no given rect
            if (rect.Equals(CCRect.Zero))
            {
                // Get the texture size as original
                CCSize textureSize = scale9Image.TextureAtlas.Texture.ContentSize;

                rect = new CCRect(0, 0, textureSize.Width, textureSize.Height);
            }

            // Set the given rect's size as original size
            m_spriteRect = rect;
            m_originalSize = rect.Size;
            m_preferredSize = m_originalSize;
            m_capInsetsInternal = capInsets;

            // Get the image edges
            float l = rect.Origin.X;
            float t = rect.Origin.Y;
            float h = rect.Size.Height;
            float w = rect.Size.Width;

            // If there is no specified center region
            if (m_capInsetsInternal.Equals(CCRect.Zero))
            {
                // Apply the 3x3 grid format
                if (rotated)
                {
                    m_capInsetsInternal = new CCRect(l + h / 3, t + w / 3, w / 3, h / 3);
                }
                else
                {
                    m_capInsetsInternal = new CCRect(l + w / 3, t + h / 3, w / 3, h / 3);
                }
            }

            //
            // Set up the image
            //
            if (rotated)
            {
                // Sprite frame is rotated

                // Centre
                centre = new CCSprite();
                centre.InitWithTexture(scale9Image.Texture, m_capInsetsInternal, true);
                scale9Image.AddChild(centre, 0, (int) Positions.pCentre);

                // Bottom
                bottom = new CCSprite();
                bottom.InitWithTexture(scale9Image.Texture, new CCRect(l,
                                                                       m_capInsetsInternal.Origin.Y,
                                                                       m_capInsetsInternal.Size.Width,
                                                                       m_capInsetsInternal.Origin.X - l),
                                       rotated
                    );
                scale9Image.AddChild(bottom, 1, (int) Positions.pBottom);

                // Top
                top = new CCSprite();
                top.InitWithTexture(scale9Image.Texture, new CCRect(m_capInsetsInternal.Origin.X + m_capInsetsInternal.Size.Height,
                                                                    m_capInsetsInternal.Origin.Y,
                                                                    m_capInsetsInternal.Size.Width,
                                                                    h - m_capInsetsInternal.Size.Height - (m_capInsetsInternal.Origin.X - l)),
                                    rotated
                    );
                scale9Image.AddChild(top, 1, (int) Positions.pTop);

                // Right
                right = new CCSprite();
                right.InitWithTexture(scale9Image.Texture, new CCRect(m_capInsetsInternal.Origin.X,
                                                                      m_capInsetsInternal.Origin.Y + m_capInsetsInternal.Size.Width,
                                                                      w - (m_capInsetsInternal.Origin.Y - t) - m_capInsetsInternal.Size.Width,
                                                                      m_capInsetsInternal.Size.Height),
                                      rotated
                    );
                scale9Image.AddChild(right, 1, (int) Positions.pRight);

                // Left
                left = new CCSprite();
                left.InitWithTexture(scale9Image.Texture, new CCRect(m_capInsetsInternal.Origin.X,
                                                                     t,
                                                                     m_capInsetsInternal.Origin.Y - t,
                                                                     m_capInsetsInternal.Size.Height),
//.........这里部分代码省略.........
开发者ID:CartBlanche,项目名称:cocos2d-xna,代码行数:101,代码来源:CCScale9Sprite.cs


注:本文中的Cocos2D.CCRect.Equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。