コード例 #1
0
ファイル: CCAnimation.cs プロジェクト: chengcong/cocos2d-xna
        public void addFrameWithFileName(string pszFileName)
        {
            CCTexture2D cCTexture2D = CCTextureCache.sharedTextureCache().addImage(pszFileName);
            CCRect      cCRect      = new CCRect(0f, 0f, 0f, 0f)
            {
                size = cCTexture2D.getContentSize()
            };
            CCSpriteFrame cCSpriteFrame = CCSpriteFrame.frameWithTexture(cCTexture2D, cCRect);

            this.m_pobFrames.Add(cCSpriteFrame);
        }
コード例 #2
0
        /** 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);
        }
コード例 #3
0
 public bool initWithTexture(CCTexture2D tex, int capacity)
 {
     this.m_blendFunc.src   = 1;
     this.m_blendFunc.dst   = 0x303;
     this.m_pobTextureAtlas = new CCTextureAtlas();
     this.m_pobTextureAtlas.initWithTexture(tex, capacity);
     this.updateBlendFunc();
     this.contentSize      = tex.getContentSize();
     base.m_pChildren      = new List <CCNode>();
     this.m_pobDescendants = new List <CCSprite>();
     return(true);
 }
コード例 #4
0
        /// <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)
        {
            if (texture == null)
            {
                throw (new ArgumentNullException("texture", "Texture cannot be null"));
            }

            CCRect rect = new CCRect();

            rect.size = texture.getContentSize();

            return(initWithTexture(texture, rect));
        }
コード例 #5
0
ファイル: CCSprite.cs プロジェクト: chengcong/cocos2d-xna
        public bool initWithFile(string fileName)
        {
            CCTexture2D texture = CCTextureCache.sharedTextureCache().addImage(fileName);

            if (texture != null)
            {
                CCRect rect = new CCRect
                {
                    size = texture.getContentSize()
                };
                return(this.initWithTexture(texture, rect));
            }
            return(false);
        }
コード例 #6
0
        /// <summary>
        /// Initializes an sprite with an image filename.
        /// The rect used will be the size of the image.
        /// The offset will be (0,0).
        /// </summary>
        public bool initWithFile(string fileName)
        {
            Debug.Assert(null != fileName, "fileName is null");

            CCTexture2D textureFromFile = CCTextureCache.sharedTextureCache().addImage(fileName);

            if (null != textureFromFile)
            {
                CCRect rect = new CCRect();
                rect.size = textureFromFile.getContentSize();
                return(initWithTexture(textureFromFile, rect));
            }

            return(false);
        }
コード例 #7
0
        /// <summary>
        ///  initializes a CCSpriteBatchNode with a texture2d and capacity of children.
        ///  The capacity will be increased in 33% in runtime if it run out of space.
        /// </summary>
        /// <param name="tex"></param>
        /// <param name="capacity"></param>
        /// <returns></returns>
        public bool initWithTexture(CCTexture2D tex, int capacity)
        {
            m_blendFunc.src = 1;      // CC_BLEND_SRC = 1
            m_blendFunc.dst = 0x0303; // CC_BLEND_DST = 0x0303

            m_pobTextureAtlas = new CCTextureAtlas();
            m_pobTextureAtlas.initWithTexture(tex, capacity);

            updateBlendFunc();

            contentSize = tex.getContentSize(); // @@ TotallyEvil - contentSize should return the size of the sprite sheet

            // no lazy alloc in this node
            m_pChildren      = new List <CCNode>();
            m_pobDescendants = new List <CCSprite>();

            return(true);
        }
コード例 #8
0
        /// <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);
        }
コード例 #9
0
ファイル: CCSprite.cs プロジェクト: Ratel13/cocos2d-x-for-xna
        /// <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)
        {
            if (texture == null)
        {
                throw (new ArgumentNullException("texture", "Texture cannot be null"));
            }

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

            return initWithTexture(texture, rect);
        }
コード例 #10
0
        /// <summary>
        ///  initializes a CCSpriteBatchNode with a texture2d and capacity of children.
        ///  The capacity will be increased in 33% in runtime if it run out of space.
        /// </summary>
        /// <param name="tex"></param>
        /// <param name="capacity"></param>
        /// <returns></returns>
        public bool initWithTexture(CCTexture2D tex, int capacity)
        {
            m_blendFunc.src = 1; // CC_BLEND_SRC = 1
            m_blendFunc.dst = 0x0303; // CC_BLEND_DST = 0x0303

            m_pobTextureAtlas = new CCTextureAtlas();
            m_pobTextureAtlas.initWithTexture(tex, capacity);

            updateBlendFunc();

            contentSize= tex.getContentSize(); // @@ TotallyEvil - contentSize should return the size of the sprite sheet

            // no lazy alloc in this node
            m_pChildren = new List<CCNode>();
            m_pobDescendants = new List<CCSprite>();

            return true;
        }