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


C# CCPoint.PixelsToPoints方法代码示例

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


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

示例1: InitWithTextureFilename

        protected virtual bool InitWithTextureFilename(String filename, CCRect rect, bool rotated, CCPoint offset,
                                            CCSize originalSize)
        {
            m_pobTexture = null;
            m_strTextureFilename = filename;
            m_obRectInPixels = rect;
            m_obRect = rect.PixelsToPoints();
            m_obOffsetInPixels = offset;
            m_obOffset = m_obOffsetInPixels.PixelsToPoints();
            m_obOriginalSizeInPixels = originalSize;
            m_obOriginalSize = m_obOriginalSizeInPixels.PixelsToPoints();
            m_bRotated = rotated;

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

示例2: CreateFontChars

        public void CreateFontChars()
        {
            int nextFontPositionX = 0;
            int nextFontPositionY = 0;
            char prev = (char) 255;
            int kerningAmount = 0;

            CCSize tmpSize = CCSize.Zero;

            int longestLine = 0;
            int totalHeight = 0;

            int quantityOfLines = 1;

            if (String.IsNullOrEmpty(m_sString))
            {
                return;
            }

            int stringLen = m_sString.Length;

            var charSet = m_pConfiguration.CharacterSet;
            if (charSet.Count == 0)
            {
                throw (new InvalidOperationException(
                    "Can not compute the size of the font because the character set is empty."));
            }

            for (int i = 0; i < stringLen - 1; ++i)
            {
                if (m_sString[i] == '\n')
                {
                    quantityOfLines++;
                }
            }

            totalHeight = m_pConfiguration.m_nCommonHeight * quantityOfLines;
            nextFontPositionY = 0 -
                                (m_pConfiguration.m_nCommonHeight - m_pConfiguration.m_nCommonHeight * quantityOfLines);

            CCBMFontConfiguration.CCBMFontDef fontDef = null;
            CCRect rect;

            for (int i = 0; i < stringLen; i++)
            {
                char c = m_sString[i];

                if (c == '\n')
                {
                    nextFontPositionX = 0;
                    nextFontPositionY -= m_pConfiguration.m_nCommonHeight;
                    continue;
                }

                if (charSet.IndexOf(c) == -1)
                {
                    CCLog.Log("Cocos2D.CCLabelBMFont: Attempted to use character not defined in this bitmap: {0}",
                              (int) c);
                    continue;
                }

                kerningAmount = this.KerningAmountForFirst(prev, c);

                // unichar is a short, and an int is needed on HASH_FIND_INT
                if (!m_pConfiguration.m_pFontDefDictionary.TryGetValue(c, out fontDef))
                {
                    CCLog.Log("cocos2d::CCLabelBMFont: characer not found {0}", (int) c);
                    continue;
                }

                rect = fontDef.rect;
                rect = rect.PixelsToPoints();

                rect.Origin.X += m_tImageOffset.X;
                rect.Origin.Y += m_tImageOffset.Y;

                CCSprite fontChar;

                //bool hasSprite = true;
                fontChar = (CCSprite) (GetChildByTag(i));
                if (fontChar != null)
                {
                    // Reusing previous Sprite
                    fontChar.Visible = true;
                }
                else
                {
                    // New Sprite ? Set correct color, opacity, etc...
                    //if( false )
                    //{
                    //    /* WIP: Doesn't support many features yet.
                    //     But this code is super fast. It doesn't create any sprite.
                    //     Ideal for big labels.
                    //     */
                    //    fontChar = m_pReusedChar;
                    //    fontChar.BatchNode = null;
                    //    hasSprite = false;
                    //}
                    //else
                    {
//.........这里部分代码省略.........
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:101,代码来源:CCLabelBMFont.cs

示例3: InitWithTexture

        protected virtual bool InitWithTexture(CCTexture2D pobTexture, CCRect rect, bool rotated, CCPoint offset,
                                    CCSize originalSize)
        {
            m_pobTexture = pobTexture;

            m_obRectInPixels = rect;
            m_obRect = rect.PixelsToPoints();
            m_obOffsetInPixels = offset;
            m_obOffset = m_obOffsetInPixels.PixelsToPoints();
            m_obOriginalSizeInPixels = originalSize;
            m_obOriginalSize = m_obOriginalSizeInPixels.PixelsToPoints();
            m_bRotated = rotated;

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


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