Beispiel #1
0
        public bool InitWithTileFile(string tile, int tileWidth, int tileHeight, int itemsToRender)
        {
            Debug.Assert(tile != null, "title should not be null");

            m_uItemWidth  = tileWidth;
            m_uItemHeight = tileHeight;

            m_cOpacity            = 255;
            m_tColor              = m_tColorUnmodified = CCTypes.CCWhite;
            m_bIsOpacityModifyRGB = true;

            m_tBlendFunc.Source      = CCMacros.CCDefaultSourceBlending;
            m_tBlendFunc.Destination = CCMacros.CCDefaultDestinationBlending;

            var pNewAtlas = new CCTextureAtlas();

            pNewAtlas.InitWithFile(tile, itemsToRender);

            TextureAtlas = pNewAtlas;

            UpdateBlendFunc();
            UpdateOpacityModifyRgb();

            CalculateMaxItems();

            m_uQuadsToDraw = itemsToRender;

            return(true);
        }
Beispiel #2
0
        /// <summary>
        /// creates a TextureAtlas with an filename and with an initial capacity for Quads.
        /// The TextureAtlas capacity can be increased in runtime.
        /// </summary>
        public static CCTextureAtlas Create(string file, int capacity)
        {
            var pTextureAtlas = new CCTextureAtlas();

            if (pTextureAtlas.InitWithFile(file, capacity))
            {
                return(pTextureAtlas);
            }

            return(null);
        }
Beispiel #3
0
        /// <summary>
        /// creates a TextureAtlas with a previously initialized Texture2D object, and
        /// with an initial capacity for n Quads.
        /// The TextureAtlas capacity can be increased in runtime.
        /// </summary>
        public static CCTextureAtlas Create(CCTexture2D texture, int capacity)
        {
            var pTextureAtlas = new CCTextureAtlas();

            if (pTextureAtlas.InitWithTexture(texture, capacity))
            {
                return(pTextureAtlas);
            }

            return(null);
        }
        public bool InitWithTexture(CCTexture2D texture, int tileWidth, int tileHeight, int itemsToRender)
        {
            m_uItemWidth  = tileWidth;
            m_uItemHeight = tileHeight;

            m_tColorUnmodified    = CCTypes.CCWhite;
            m_bIsOpacityModifyRGB = true;

            m_tBlendFunc = CCBlendFunc.AlphaBlend;

            m_pTextureAtlas = new CCTextureAtlas();
            m_pTextureAtlas.InitWithTexture(texture, itemsToRender);

            UpdateBlendFunc();
            UpdateOpacityModifyRgb();

            CalculateMaxItems();

            m_uQuadsToDraw = itemsToRender;

            return(true);
        }
Beispiel #5
0
        protected virtual bool InitWithTexture(CCTexture2D tex, int capacity)
        {
            m_blendFunc = CCBlendFunc.AlphaBlend;

            m_pobTextureAtlas = new CCTextureAtlas();

            if (capacity == 0)
            {
                capacity = kDefaultSpriteBatchCapacity;
            }

            ContentSize = tex.ContentSize; // @@ TotallyEvil - contentSize should return the size of the sprite sheet
            m_pobTextureAtlas.InitWithTexture(tex, capacity);

            UpdateBlendFunc();

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

            return(true);
        }
Beispiel #6
0
        public Atlas1()
        {
            m_textureAtlas = CCTextureAtlas.Create(TestResource.s_AtlasTest, 3);
            //m_textureAtlas.retain();

            CCSize s = CCDirector.SharedDirector.WinSize;

            //
            // Notice: u,v tex coordinates are inverted
            //
            //ccV3F_C4B_T2F_Quad quads[] =
            //{
            //    {
            //        {{0,0,0},new ccColor4B(0,0,255,255),{0.0f,1.0f},},				// bottom left
            //        {{s.width,0,0},new ccColor4B(0,0,255,0),{1.0f,1.0f},},			// bottom right
            //        {{0,s.height,0},new ccColor4B(0,0,255,0),{0.0f,0.0f},},	    // top left
            //        {{s.width,s.height,0},{0,0,255,255},{1.0f,0.0f},},	                // top right
            //    },
            //    {
            //        {{40,40,0}, new ccColor4B(255,255,255,255),{0.0f,0.2f},},			// bottom left
            //        {{120,80,0},new ccColor4B(255,0,0,255),{0.5f,0.2f},},			        // bottom right
            //        {{40,160,0},new ccColor4B(255,255,255,255),{0.0f,0.0f},},		    // top left
            //        {{160,160,0},new ccColor4B(0,255,0,255),{0.5f,0.0f},},			    // top right
            //    },

            //    {
            //        {{s.width/2,40,0},new ccColor4B(255,0,0,255),{0.0f,1.0f},},		         // bottom left
            //        {{s.width,40,0},new ccColor4B(0,255,0,255),{1.0f,1.0f},},		        // bottom right
            //        {{s.width/2-50,200,0},new ccColor4B(0,0,255,255),{0.0f,0.0f},},		// top left
            //        {{s.width,100,0},new ccColor4B(255,255,0,255),{1.0f,0.0f},},		    // top right
            //    },
            //};

            //for( int i=0;i<3;i++)
            //{
            //    m_textureAtlas.updateQuad(&quads[i], i);
            //}
        }
        protected virtual bool InitWithTexture(CCTexture2D tex, int capacity)
        {
            m_blendFunc = CCBlendFunc.AlphaBlend;

            m_pobTextureAtlas = new CCTextureAtlas();

            if (capacity == 0)
            {
                capacity = kDefaultSpriteBatchCapacity;
            }

            ContentSize= tex.ContentSize; // @@ TotallyEvil - contentSize should return the size of the sprite sheet
            m_pobTextureAtlas.InitWithTexture(tex, capacity);

            UpdateBlendFunc();

            // no lazy alloc in this node
            m_pChildren = new CCRawList<CCNode>(capacity);

            m_pobDescendants = new CCRawList<CCSprite>(capacity);

            return true;
        }
Beispiel #8
0
        public Atlas1()
        {
            m_textureAtlas = CCTextureAtlas.Create(TestResource.s_AtlasTest, 3);
            //m_textureAtlas.retain();

            CCSize s = CCDirector.SharedDirector.WinSize;

            //
            // Notice: u,v tex coordinates are inverted
            //
            CCV3F_C4B_T2F_Quad[] quads = 
            {
               new  CCV3F_C4B_T2F_Quad() {
                    BottomLeft = new CCV3F_C4B_T2F() { Vertices = new CCVertex3F(0,0,0), Colors = new CCColor4B(0,0,255,255),TexCoords = new CCTex2F(0.0f,1.0f)},				// bottom left
                    BottomRight = new CCV3F_C4B_T2F() { Vertices = new CCVertex3F(s.Width,0,0), Colors = new CCColor4B(0,0,255,0),TexCoords = new CCTex2F(1.0f,1.0f)},			// bottom right
                    TopLeft = new CCV3F_C4B_T2F() { Vertices = new CCVertex3F(0,s.Height,0), Colors = new CCColor4B(0,0,255,0),TexCoords = new CCTex2F(0.0f,0.0f)},			// bottom right
                    TopRight = new CCV3F_C4B_T2F() { Vertices = new CCVertex3F(s.Width,s.Height,0), Colors = new CCColor4B(0,0,255,255),TexCoords = new CCTex2F(1.0f,0.0f)},			// bottom right
                },		
               new  CCV3F_C4B_T2F_Quad() {
                    BottomLeft = new CCV3F_C4B_T2F() { Vertices = new CCVertex3F(40,40,0), Colors = new CCColor4B(255,255,255,255),TexCoords = new CCTex2F(0.0f,0.2f)},				// bottom left
                    BottomRight = new CCV3F_C4B_T2F() { Vertices = new CCVertex3F(120,80,0), Colors = new CCColor4B(255,0,0,255),TexCoords = new CCTex2F(0.5f,0.2f)},			// bottom right
                    TopLeft = new CCV3F_C4B_T2F() { Vertices = new CCVertex3F(40,160,0), Colors = new CCColor4B(255,255,255,255),TexCoords = new CCTex2F(0.0f,0.0f)},			// bottom right
                    TopRight = new CCV3F_C4B_T2F() { Vertices = new CCVertex3F(160,160,0), Colors = new CCColor4B(0,255,0,255),TexCoords = new CCTex2F(0.5f,0.0f)},			// bottom right
                },		
               new  CCV3F_C4B_T2F_Quad() {
                    BottomLeft = new CCV3F_C4B_T2F() { Vertices = new CCVertex3F(s.Width/2,40,0), Colors = new CCColor4B(255,0,0,255),TexCoords = new CCTex2F(0.0f,1.0f)},				// bottom left
                    BottomRight = new CCV3F_C4B_T2F() { Vertices = new CCVertex3F(s.Width,40,0), Colors = new CCColor4B(0,255,0,255),TexCoords = new CCTex2F(1.0f,1.0f)},			// bottom right
                    TopLeft = new CCV3F_C4B_T2F() { Vertices = new CCVertex3F(s.Width/2-50,200,0), Colors = new CCColor4B(0,0,255,255),TexCoords = new CCTex2F(0.0f,0.0f)},			// bottom right
                    TopRight = new CCV3F_C4B_T2F() { Vertices = new CCVertex3F(s.Width,100,0), Colors = new CCColor4B(255,255,0,255),TexCoords = new CCTex2F(1.0f,0.0f)},			// bottom right
                },		
            };

            for( int i=0;i<3;i++) 
            {
                m_textureAtlas.UpdateQuad(ref quads[i], i);
            }
        }
Beispiel #9
0
        public bool InitWithTileFile(string tile, int tileWidth, int tileHeight, int itemsToRender)
        {
            Debug.Assert(tile != null, "title should not be null");

            m_uItemWidth = tileWidth;
            m_uItemHeight = tileHeight;

            m_cOpacity = 255;
            m_tColor = m_tColorUnmodified = CCTypes.CCWhite;
            m_bIsOpacityModifyRGB = true;

            m_tBlendFunc.Source = CCMacros.CCDefaultSourceBlending;
            m_tBlendFunc.Destination = CCMacros.CCDefaultDestinationBlending;

            var pNewAtlas = new CCTextureAtlas();
            pNewAtlas.InitWithFile(tile, itemsToRender);

            TextureAtlas = pNewAtlas;

            UpdateBlendFunc();
            UpdateOpacityModifyRgb();

            CalculateMaxItems();

            m_uQuadsToDraw = itemsToRender;

            return true;
        }
Beispiel #10
0
        public Atlas1()
        {
            m_textureAtlas = CCTextureAtlas.Create(TestResource.s_AtlasTest, 3);
            //m_textureAtlas.retain();

            CCSize s = CCDirector.SharedDirector.WinSize;

            //
            // Notice: u,v tex coordinates are inverted
            //
            //ccV3F_C4B_T2F_Quad quads[] = 
            //{
            //    {
            //        {{0,0,0},new ccColor4B(0,0,255,255),{0.0f,1.0f},},				// bottom left
            //        {{s.width,0,0},new ccColor4B(0,0,255,0),{1.0f,1.0f},},			// bottom right
            //        {{0,s.height,0},new ccColor4B(0,0,255,0),{0.0f,0.0f},},	    // top left
            //        {{s.width,s.height,0},{0,0,255,255},{1.0f,0.0f},},	                // top right
            //    },		
            //    {
            //        {{40,40,0}, new ccColor4B(255,255,255,255),{0.0f,0.2f},},			// bottom left
            //        {{120,80,0},new ccColor4B(255,0,0,255),{0.5f,0.2f},},			        // bottom right
            //        {{40,160,0},new ccColor4B(255,255,255,255),{0.0f,0.0f},},		    // top left
            //        {{160,160,0},new ccColor4B(0,255,0,255),{0.5f,0.0f},},			    // top right
            //    },

            //    {
            //        {{s.width/2,40,0},new ccColor4B(255,0,0,255),{0.0f,1.0f},},		         // bottom left
            //        {{s.width,40,0},new ccColor4B(0,255,0,255),{1.0f,1.0f},},		        // bottom right
            //        {{s.width/2-50,200,0},new ccColor4B(0,0,255,255),{0.0f,0.0f},},		// top left
            //        {{s.width,100,0},new ccColor4B(255,255,0,255),{1.0f,0.0f},},		    // top right
            //    },		
            //};

            //for( int i=0;i<3;i++) 
            //{
            //    m_textureAtlas.updateQuad(&quads[i], i);
            //}
        }
        /// <summary>
        /// creates a TextureAtlas with a previously initialized Texture2D object, and
        /// with an initial capacity for n Quads. 
        /// The TextureAtlas capacity can be increased in runtime.
        /// </summary>
        public static CCTextureAtlas Create(CCTexture2D texture, int capacity)
        {
            var pTextureAtlas = new CCTextureAtlas();
            if (pTextureAtlas.InitWithTexture(texture, capacity))
            {
                return pTextureAtlas;
            }

            return null;
        }
        /// <summary>
        /// creates a TextureAtlas with an filename and with an initial capacity for Quads.
        /// The TextureAtlas capacity can be increased in runtime.
        /// </summary>
        public static CCTextureAtlas Create(string file, int capacity)
        {
            var pTextureAtlas = new CCTextureAtlas();
            if (pTextureAtlas.InitWithFile(file, capacity))
            {
                return pTextureAtlas;
            }

            return null;
        }
Beispiel #13
0
        public bool InitWithTexture(CCTexture2D texture, int tileWidth, int tileHeight, int itemsToRender)
        {
            m_uItemWidth = tileWidth;
            m_uItemHeight = tileHeight;

            m_tColorUnmodified = CCTypes.CCWhite;
            m_bIsOpacityModifyRGB = true;

            m_tBlendFunc = CCBlendFunc.AlphaBlend; 

            m_pTextureAtlas = new CCTextureAtlas();
            m_pTextureAtlas.InitWithTexture(texture, itemsToRender);

            UpdateBlendFunc();
            UpdateOpacityModifyRgb();

            CalculateMaxItems();

            m_uQuadsToDraw = itemsToRender;

            return true;
        }
        void _spAtlasPage_createTexture(AtlasPage self, string path)
        {
            CCTexture2D texture = CCTextureCache.SharedTextureCache.AddImage(path);
            CCTextureAtlas textureAtlas = new CCTextureAtlas();
            textureAtlas.InitWithTexture(texture, 128);

            textureAtlas.DrawQuads(); //retain();

            self.rendererObject = textureAtlas;
            self.width = texture.PixelsWide;
            self.height = texture.PixelsHigh;
        }