• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# cocos2d.CCRect类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



CCRect类属于cocos2d命名空间,在下文中一共展示了CCRect类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Selection

        public Selection(Word p_StudyInfo, bool p_IsAnswer,Int32 p_Width,Int32 p_Height)
        {
            base.init();
            this.StudyInfo = p_StudyInfo;

            CCTexture2D texture = new CCTexture2D();
            texture.initWithTexture(PictureManager.GetTexture2D(p_StudyInfo));

            if (p_Width < texture.ContentSizeInPixels.width)
            {
                this.scaleX = p_Width / texture.ContentSizeInPixels.width;
            }
            if (p_Height < texture.ContentSizeInPixels.height)
            {
                this.scaleY = p_Height / texture.ContentSizeInPixels.height;
            }
            this.contentSize.width = p_Width;
            this.contentSize.height = p_Height;

            CCRect rect = new CCRect();
            rect.size = new CCSize(texture.ContentSizeInPixels.width, texture.ContentSizeInPixels.height);
            this.initWithTexture(texture, rect);

            this.IsAnswer = p_IsAnswer;
            LoadResultPeople();
        }
开发者ID:tianjing,项目名称:SayWordByPicture,代码行数:26,代码来源:Selection.cs


示例2: CCSprite

 public CCSprite(string fileName, CCRect rect)
 {
     if (!InitWithFile(fileName, rect))
     {
         CCLog.Log("CCSprite (string fileName, CCRect rect): Problems initializing class");
     }
 }
开发者ID:HarkDev,项目名称:cocos2d-xna,代码行数:7,代码来源:CCSprite.cs


示例3: getRect

 public static CCRect getRect(CCNode node)
 {
     CCRect rc = new CCRect();
     rc.Origin = node.Position;
     rc.Size = node.ContentSize;
     rc.Origin.X -= rc.Size.Width / 2;
     rc.Origin.Y -= rc.Size.Height / 2;
     return rc;
 }
开发者ID:eickegao,项目名称:cocos2d-xna,代码行数:9,代码来源:TextInputTestScene.cs


示例4: getRect

 public static CCRect getRect(CCNode pNode)
 {
     CCRect rc = new CCRect();
     rc.origin = pNode.position;
     rc.size = pNode.contentSize;
     rc.origin.x -= rc.size.width / 2;
     rc.origin.y -= rc.size.height / 2;
     return rc;
 }
开发者ID:Ratel13,项目名称:cocos2d-x-for-xna,代码行数:9,代码来源:TextInputTestScene.cs


示例5: addFrameWithFileName

 /** Adds a frame with an image filename. Internally it will create a CCSpriteFrame and it will add it.
 Added to facilitate the migration from v0.8 to v0.9.
 */
 public void addFrameWithFileName(string pszFileName)
 {
     CCTexture2D pTexture = CCTextureCache.sharedTextureCache().addImage(pszFileName);
     //CCRect rect = CCRectZero;
     CCRect rect = new CCRect(0, 0, 0, 0);
     rect.size = pTexture.getContentSize();
     CCSpriteFrame pFrame = CCSpriteFrame.frameWithTexture(pTexture, rect);
     //// m_pobFrames.addObject(pFrame);
     m_pobFrames.Add(pFrame);
 }
开发者ID:Ratel13,项目名称:cocos2d-x-for-xna,代码行数:13,代码来源:CCAnimation.cs


示例6: rectForGID

 public CCRect rectForGID(int gid)
 {
     CCRect rect = new CCRect();
     rect.size = m_tTileSize;
     gid = gid - m_uFirstGid;
     int max_x = (int)((m_tImageSize.width - m_uMargin * 2 + m_uSpacing) / (m_tTileSize.width + m_uSpacing));
     //	int max_y = (imageSize.height - margin*2 + spacing) / (tileSize.height + spacing);
     rect.origin.x = (gid % max_x) * (m_tTileSize.width + m_uSpacing) + m_uMargin;
     rect.origin.y = (gid / max_x) * (m_tTileSize.height + m_uSpacing) + m_uMargin;
     return rect;
 }
开发者ID:liwq-net,项目名称:cocos2d-for-xna-windows,代码行数:11,代码来源:CCTMXTilesetInfo.cs


示例7: CCRectUnion

        public static CCRect CCRectUnion(CCRect src1, CCRect src2)
        {
            CCRect result;

            float x1 = Math.Min(src1.MinX, src2.MinX);
            float y1 = Math.Min(src1.MinY, src2.MinY);
            float x2 = Math.Max(src1.MaxX, src2.MaxX);
            float y2 = Math.Max(src1.MaxY, src2.MaxY);

            result.Origin = new CCPoint(x1,x2);
            result.Size = new CCSize(x2-x1, y2-y1);
            return result;
        }
开发者ID:HarkDev,项目名称:cocos2d-xna,代码行数:13,代码来源:CCControlUtils.cs


示例8: CCRectApplyAffineTransform

        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));
        }
开发者ID:Ratel13,项目名称:cocos2d-x-for-xna,代码行数:19,代码来源:CCAffineTransform.cs


示例9: initWithTarget

        public bool initWithTarget(CCNode followedNode, CCRect rect)
        {
            Debug.Assert(followedNode != null);

            m_pobFollowedNode = followedNode;
            m_bBoundarySet = true;
            m_bBoundaryFullyCovered = false;

            CCSize winSize = CCDirector.sharedDirector().getWinSize();
            m_obFullScreenSize = new CCPoint(winSize.width, winSize.height);
            m_obHalfScreenSize = CCPointExtension.ccpMult(m_obFullScreenSize, 0.5f);

            m_fLeftBoundary = -((rect.origin.x + rect.size.width) - m_obFullScreenSize.x);
            m_fRightBoundary = -rect.origin.x;
            m_fLeftBoundary = -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:Ratel13,项目名称:cocos2d-x-for-xna,代码行数:37,代码来源:CCFollow.cs


示例10: CCScale9Sprite

 public CCScale9Sprite(CCRect capInsets)
 {
     InitWithBatchNode(scale9Image, m_spriteRect, capInsets);
 }
开发者ID:HarkDev,项目名称:cocos2d-xna,代码行数:4,代码来源:CCScale9Sprite.cs


示例11: InitWithBatchNode

        public bool InitWithBatchNode(CCSpriteBatchNode batchnode, CCRect rect, bool rotated, CCRect capInsets)
        {
            if (batchnode != null)
            {
                UpdateWithBatchNode(batchnode, rect, rotated, capInsets);
                AnchorPoint = new CCPoint(0.5f, 0.5f);
            }
            m_positionsAreDirty = true;

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


示例12: 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:HarkDev,项目名称:cocos2d-xna,代码行数:101,代码来源:CCScale9Sprite.cs


示例13: ResizableSpriteWithCapInsets

 public CCScale9Sprite ResizableSpriteWithCapInsets(CCRect capInsets)
 {
     var pReturn = new CCScale9Sprite();
     pReturn.InitWithBatchNode(scale9Image, m_spriteRect, capInsets);
     return pReturn;
 }
开发者ID:homocury,项目名称:cocos2d-xna,代码行数:6,代码来源:CCScale9Sprite.cs


示例14: initWithTexture

        /// <summary>
        /// Initializes an sprite with a texture.
        /// The rect used will be the size of the texture.
        /// The offset will be (0,0).
        /// </summary>
        public bool initWithTexture(CCTexture2D texture)
        {
            Debug.Assert(texture != null);

            CCRect rect = new CCRect();
            rect.size = texture.getContentSize();

            return initWithTexture(texture, rect);
        }
开发者ID:Openxlive,项目名称:cocos2d-x-for-xna,代码行数:14,代码来源:CCSprite.cs


示例15: InitWithFile

 public bool InitWithFile(CCRect capInsets, string file)
 {
     bool pReturn = InitWithFile(file, CCRect.Zero, capInsets);
     return pReturn;
 }
开发者ID:homocury,项目名称:cocos2d-xna,代码行数:5,代码来源:CCScale9Sprite.cs


示例16: setTextureWithRect

        /** Sets a new texture with a rect. The rect is in Points.
	    @since v0.99.4
	    */
	    public void setTextureWithRect(CCTexture2D texture, CCRect rect)
        {
            // Only update the texture if is different from the current one
	        if( null == this.Texture || texture.Name != this.Texture.Name )
	        {
		        base.Texture = texture;
	        }

	        initTexCoordsWithRect(rect);
        }
开发者ID:Ratel13,项目名称:cocos2d-x-for-xna,代码行数:13,代码来源:CCParticleSystemQuad.cs


示例17: InitWithSpriteFrameName

        internal virtual bool InitWithSpriteFrameName(string spriteFrameName, CCRect capInsets)
        {
            Debug.Assert(spriteFrameName != null, "Invalid spriteFrameName for sprite");

            CCSpriteFrame frame = CCSpriteFrameCache.SharedSpriteFrameCache.SpriteFrameByName(spriteFrameName);
            bool pReturn = InitWithSpriteFrame(frame, capInsets);
            return pReturn;
        }
开发者ID:HarkDev,项目名称:cocos2d-xna,代码行数:8,代码来源:CCScale9Sprite.cs


示例18: InitWithFile

 internal virtual bool InitWithFile(CCRect capInsets, string file)
 {
     bool pReturn = InitWithFile(file, CCRect.Zero, capInsets);
     return pReturn;
 }
开发者ID:HarkDev,项目名称:cocos2d-xna,代码行数:5,代码来源:CCScale9Sprite.cs


示例19: boundingBoxInPixels

 /// <summary>
 /// returns a "local" axis aligned bounding box of the node in pixels.
 /// The returned box is relative only to its parent.
 /// The returned box is in Points.
 /// @since v0.99.5
 /// </summary>
 public CCRect boundingBoxInPixels()
 {
     CCRect rect = new CCRect(0, 0, m_tContentSizeInPixels.width, m_tContentSizeInPixels.height);
     return CCAffineTransform.CCRectApplyAffineTransform(rect, nodeToParentTransform());
 }
开发者ID:ChowZenki,项目名称:cocos2d-x-for-xna,代码行数:11,代码来源:CCNode.cs


示例20: InitWithSpriteFrame

        internal virtual bool InitWithSpriteFrame(CCSpriteFrame spriteFrame, CCRect capInsets)
        {
            Debug.Assert(spriteFrame != null, "Sprite frame must be not nil");

            CCSpriteBatchNode batchnode = new CCSpriteBatchNode(spriteFrame.Texture, 9);
            bool pReturn = InitWithBatchNode(batchnode, spriteFrame.Rect, spriteFrame.IsRotated, capInsets);
            return pReturn;
        }
开发者ID:HarkDev,项目名称:cocos2d-xna,代码行数:8,代码来源:CCScale9Sprite.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# cocos2d.CCScene类代码示例发布时间:2022-05-26
下一篇:
C# cocos2d.CCPoint类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap