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


C# cocos2d.CCSize类代码示例

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


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

示例1: updateSize

 public void updateSize(CCPoint touchLocation)
 {
     CCSize s = CCDirector.SharedDirector.WinSize;
     CCSize newSize = new CCSize(Math.Abs(touchLocation.X - s.Width / 2) * 2, Math.Abs(touchLocation.Y - s.Height / 2) * 2);
     CCLayerColor l = (CCLayerColor)GetChildByTag(kTagLayer);
     l.ContentSize = newSize;
 }
开发者ID:KogleDK,项目名称:cocos2d-xna-1,代码行数:7,代码来源:LayerTest1.cs

示例2: CCSizeApplyAffineTransform

 public static CCSize CCSizeApplyAffineTransform(CCSize size, CCAffineTransform t)
 {
     CCSize s = new CCSize();
     s.width = (float)((double)t.a * size.width + (double)t.c * size.height);
     s.height = (float)((double)t.b * size.width + (double)t.d * size.height);
     return s;
 }
开发者ID:Ratel13,项目名称:cocos2d-x-for-xna,代码行数:7,代码来源:CCAffineTransform.cs

示例3: Create

 public static CCGrid3D Create(CCGridSize gridSize, CCSize size)
 {
     var pRet = new CCGrid3D();
     if (pRet.InitWithSize(gridSize, size))
     {
         return pRet;
     }
     return null;
 }
开发者ID:eickegao,项目名称:cocos2d-xna,代码行数:9,代码来源:CCGrid3D.cs

示例4: updateSize

 public void updateSize(CCTouch touch)
 {
     CCPoint touchLocation = touch.locationInView(touch.view());
     touchLocation = CCDirector.sharedDirector().convertToGL(touchLocation);
     CCSize s = CCDirector.sharedDirector().getWinSize();
     CCSize newSize = new CCSize(Math.Abs(touchLocation.x - s.width / 2) * 2, Math.Abs(touchLocation.y - s.height / 2) * 2);
     CCLayerColor l = (CCLayerColor)getChildByTag(kTagLayer);
     l.contentSize = newSize;
 }
开发者ID:Ratel13,项目名称:cocos2d-x-for-xna,代码行数:9,代码来源:LayerTest1.cs

示例5: labelWithString

        /// <summary>
        /// creates a CCLabelTTF from a fontname, alignment, dimension and font size
        /// </summary>
        public static CCLabelTTF labelWithString(string label, CCSize dimensions, CCTextAlignment alignment, string fontName, float fontSize)
        {
            CCLabelTTF pRet = new CCLabelTTF();
            if (pRet != null && pRet.initWithString(label, dimensions, alignment, fontName, fontSize))
            {
                return pRet;
            }

            return null;
        }
开发者ID:liwq-net,项目名称:cocos2d-for-xna-windows,代码行数:13,代码来源:CCLabelTTF.cs

示例6: BackGroundInit

        /// <summary>
        /// 背景初始化
        /// </summary>
        private void BackGroundInit(CCSize p_Size)
        {
            CCTexture2D backgroud = Media.PictureManager.GetCCTexture2DWithFile("image/BackGround");
            CCSprite pSprite = CCSprite.spriteWithTexture(backgroud);
            // position the sprite on the center of the screen
            pSprite.position = new CCPoint(p_Size.width / 2, p_Size.height / 2);

            // add the sprite as a child to this layer
            this.addChild(pSprite, 0);
        }
开发者ID:tianjing,项目名称:SayWordByPicture,代码行数:13,代码来源:StartLayer.cs

示例7: showFont

        public void showFont(string pFont)
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            var blockSize = new CCSize(s.Width / 3, 200);
            float fontSize = 26;

            RemoveChildByTag(kTagLabel1, true);
            RemoveChildByTag(kTagLabel2, true);
            RemoveChildByTag(kTagLabel3, true);
            RemoveChildByTag(kTagLabel4, true);

            CCLabelTTF top = new CCLabelTTF(pFont, pFont, 24);
            CCLabelTTF left = new CCLabelTTF("alignment left", pFont, fontSize,
                                                blockSize, CCTextAlignment.CCTextAlignmentLeft,
                                                FontTestScene.verticalAlignment[FontTestScene.vAlignIdx]);
            CCLabelTTF center = new CCLabelTTF("alignment center", pFont, fontSize,
                                                  blockSize, CCTextAlignment.CCTextAlignmentCenter,
                                                  FontTestScene.verticalAlignment[FontTestScene.vAlignIdx]);
            CCLabelTTF right = new CCLabelTTF("alignment right", pFont, fontSize,
                                                 blockSize, CCTextAlignment.CCTextAlignmentRight,
                                                 FontTestScene.verticalAlignment[FontTestScene.vAlignIdx]);

            CCLayerColor leftColor = new CCLayerColor(new CCColor4B(100, 100, 100, 255), blockSize.Width, blockSize.Height);
            CCLayerColor centerColor = new CCLayerColor(new CCColor4B(200, 100, 100, 255), blockSize.Width, blockSize.Height);
            CCLayerColor rightColor = new CCLayerColor(new CCColor4B(100, 100, 200, 255), blockSize.Width, blockSize.Height);

            leftColor.IgnoreAnchorPointForPosition = false;
            centerColor.IgnoreAnchorPointForPosition = false;
            rightColor.IgnoreAnchorPointForPosition = false;

            top.AnchorPoint = new CCPoint(0.5f, 1);
            left.AnchorPoint = new CCPoint(0, 0.5f);
            leftColor.AnchorPoint = new CCPoint(0, 0.5f);
            center.AnchorPoint = new CCPoint(0, 0.5f);
            centerColor.AnchorPoint = new CCPoint(0, 0.5f);
            right.AnchorPoint = new CCPoint(0, 0.5f);
            rightColor.AnchorPoint = new CCPoint(0, 0.5f);

            top.Position = new CCPoint(s.Width / 2, s.Height - 20);
            left.Position = new CCPoint(0, s.Height / 2);
            leftColor.Position = left.Position;
            center.Position = new CCPoint(blockSize.Width, s.Height / 2);
            centerColor.Position = center.Position;
            right.Position = new CCPoint(blockSize.Width * 2, s.Height / 2);
            rightColor.Position = right.Position;

            AddChild(leftColor, -1);
            AddChild(left, 0, kTagLabel1);
            AddChild(rightColor, -1);
            AddChild(right, 0, kTagLabel2);
            AddChild(centerColor, -1);
            AddChild(center, 0, kTagLabel3);
            AddChild(top, 0, kTagLabel4);
        }
开发者ID:HarkDev,项目名称:cocos2d-xna,代码行数:55,代码来源:FontTest.cs

示例8: OnHandlePropTypeSize

 protected override void OnHandlePropTypeSize(CCNode node, CCNode parent, string propertyName, CCSize pSize, CCBReader reader)
 {
     if (propertyName == PROPERTY_CONTENTSIZE)
     {
         ((CCScrollView) node).ViewSize = pSize;
     }
     else
     {
         base.OnHandlePropTypeSize(node, parent, propertyName, pSize, reader);
     }
 }
开发者ID:eickegao,项目名称:cocos2d-xna,代码行数:11,代码来源:CCScrollViewLoader.cs

示例9: initWithPlaceHolder

        //////////////////////////////////////////////////////////////////////////
        // initialize
        //////////////////////////////////////////////////////////////////////////

        /** initializes the CCTextFieldTTF with a font name, alignment, dimension and font size */
        public bool initWithPlaceHolder(string placeholder, CCSize dimensions, CCTextAlignment alignment, string fontName, float fontSize)
        {
            if (placeholder != null)
            {
                //CC_SAFE_DELETE(m_pPlaceHolder);
                m_pPlaceHolder = placeholder;
            }

            return cclabelttf.initWithString(m_pPlaceHolder, dimensions, alignment, fontName, fontSize);
            //throw new NotFiniteNumberException();
        }
开发者ID:Ratel13,项目名称:cocos2d-x-for-xna,代码行数:16,代码来源:CCTextFieldTTF+.cs

示例10: InitWithTileFile

        public bool InitWithTileFile(string tile, string mapFile, int tileWidth, int tileHeight)
        {
            LoadTgAfile(mapFile);
            CalculateItemsToRender();

            if (base.InitWithTileFile(tile, tileWidth, tileHeight, m_nItemsToRender))
            {
                m_tColor = CCTypes.CCWhite;
                m_pPosToAtlasIndex = new Dictionary<CCGridSize, int>();
                UpdateAtlasValues();
                ContentSize = new CCSize(m_pTGAInfo.width * m_uItemWidth, m_pTGAInfo.height * m_uItemHeight);
                return true;
            }
            return false;
        }
开发者ID:homocury,项目名称:cocos2d-xna,代码行数:15,代码来源:CCTileMapAtlas.cs

示例11: initWithString

        /// <summary>
        /// initializes the CCLabelTTF with a font name, alignment, dimension and font size
        /// </summary>
        public bool initWithString(string label, CCSize dimensions, CCTextAlignment alignment, string fontName, float fontSize)
        {
            Debug.Assert(label != null);
            if (init())
            {
                m_tDimensions = new CCSize(dimensions.width * CCDirector.sharedDirector().ContentScaleFactor, dimensions.height * CCDirector.sharedDirector().ContentScaleFactor);
                m_eAlignment = alignment;

                m_pFontName = fontName;

                m_fFontSize = fontSize * CCDirector.sharedDirector().ContentScaleFactor;
                this.setString(label);
                return true;
            }
            return false;
        }
开发者ID:Ratel13,项目名称:cocos2d-x-for-xna,代码行数:19,代码来源:CCLabelTTF.cs

示例12: textFieldWithPlaceHolder

        //char * description();

        //////////////////////////////////////////////////////////////////////////
        // static constructor
        //////////////////////////////////////////////////////////////////////////

        /** creates a CCTextFieldTTF from a fontname, alignment, dimension and font size */
        public static CCTextFieldTTF textFieldWithPlaceHolder(string placeholder, CCSize dimensions, CCTextAlignment alignment, string fontName, float fontSize)
        {
            CCTextFieldTTF pRet = new CCTextFieldTTF();
            if (pRet != null && pRet.initWithPlaceHolder("", dimensions, alignment, fontName, fontSize))
            {
                //pRet->autorelease();
                if (placeholder != null)
                {
                    pRet.PlaceHolder = placeholder;
                }
                return pRet;
            }
            //CC_SAFE_DELETE(pRet);
            return null;
            throw new NotFiniteNumberException();
        }
开发者ID:Ratel13,项目名称:cocos2d-x-for-xna,代码行数:23,代码来源:CCTextFieldTTF+.cs

示例13: CCSizeFromString

        public static CCSize CCSizeFromString(string pszContent)
        {
            CCSize ret = new CCSize();

            do
            {
                List<string> strs = new List<string>();
                if (!CCUtils.SplitWithForm(pszContent, strs)) break;

                float width = CCUtils.CCParseFloat(strs[0]);
                float height = CCUtils.CCParseFloat(strs[1]);

                ret = new CCSize(width, height);
            } while (false);

            return ret;
        }
开发者ID:CartBlanche,项目名称:cocos2d-xna,代码行数:17,代码来源:CCSizeConverter.cs

示例14: MathSize

        /// <summary>
        /// 获取均分屏幕的尺寸 默认屏幕宽800 高480
        /// </summary>
        /// <param name="p_Width">800</param>
        /// <param name="p_Height">480</param>
        /// <param name="p_AverageNumber">均分</param>
        /// <returns></returns>
        public static CCSize MathSize(Int32 p_Width, Int32 p_Height, Int32 p_AverageNumber,Int32 p_While)
        {
            CCSize size = new CCSize();
            size.width = p_Width / ((p_AverageNumber / 2)==1?2:(p_AverageNumber / 2));

            if (p_AverageNumber / 2 > 1)
            {
                size.height = p_Height / 2;
            }
            else
            {
                size.height = p_Height;
            }
            size.width -= p_While*2;
            size.height -= p_While * 2;
            return size;
        }
开发者ID:tianjing,项目名称:SayWordByPicture,代码行数:24,代码来源:ScreenHelper.cs

示例15: GetAbsolutePosition

        public static CCPoint GetAbsolutePosition(CCPoint pt, kCCBPositionType nType, CCSize containerSize, string pPropName)
        {
            CCPoint absPt = new CCPoint(0, 0);

            if (nType == kCCBPositionType.kCCBPositionTypeRelativeBottomLeft)
            {
                absPt = pt;
            }
            else if (nType == kCCBPositionType.kCCBPositionTypeRelativeTopLeft)
            {
                absPt.X = pt.X;
                absPt.Y = containerSize.Height - pt.Y;
            }
            else if (nType == kCCBPositionType.kCCBPositionTypeRelativeTopRight)
            {
                absPt.X = containerSize.Width - pt.X;
                absPt.Y = containerSize.Height - pt.Y;
            }
            else if (nType == kCCBPositionType.kCCBPositionTypeRelativeBottomRight)
            {
                absPt.X = containerSize.Width - pt.X;
                absPt.Y = pt.Y;
            }
            else if (nType == kCCBPositionType.kCCBPositionTypePercent)
            {
                absPt.X = (int) (containerSize.Width * pt.X / 100.0f);
                absPt.Y = (int) (containerSize.Height * pt.Y / 100.0f);
            }
            else if (nType == kCCBPositionType.kCCBPositionTypeMultiplyResolution)
            {
                float resolutionScale = CCBReader.ResolutionScale;

                absPt.X = pt.X * resolutionScale;
                absPt.Y = pt.Y * resolutionScale;
            }

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


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