public bool initWithTileFile(string tile, int tileWidth, int tileHeight, int itemsToRender) { this.m_uItemWidth = tileWidth; this.m_uItemHeight = tileHeight; this.m_cOpacity = 255; ccColor3B _ccColor3B = ccTypes.ccWHITE; ccColor3B _ccColor3B1 = _ccColor3B; this.m_tColorUnmodified = _ccColor3B; this.m_tColor = _ccColor3B1; this.m_bIsOpacityModifyRGB = true; this.m_tBlendFunc.src = ccMacros.CC_BLEND_SRC; this.m_tBlendFunc.dst = ccMacros.CC_BLEND_DST; this.m_pTextureAtlas = new CCTextureAtlas(); this.m_pTextureAtlas.initWithFile(tile, itemsToRender); if (this.m_pTextureAtlas == null) { CCLog.Log("cocos2d: Could not initialize CCAtlasNode. Invalid Texture."); return(false); } this.updateBlendFunc(); this.updateOpacityModifyRGB(); this.calculateMaxItems(); this.m_uQuadsToDraw = itemsToRender; return(true); }
/// <summary> /// initializes an CCAtlasNode with an Atlas file the width and height of each item and the quantity of items to render /// </summary> public bool initWithTileFile(string tile, int tileWidth, int tileHeight, int itemsToRender) { Debug.Assert(tile != null); m_uItemWidth = tileWidth; m_uItemHeight = tileHeight; m_cOpacity = 255; m_tColor = m_tColorUnmodified = ccTypes.ccWHITE; m_bIsOpacityModifyRGB = true; m_tBlendFunc.src = ccMacros.CC_BLEND_SRC; m_tBlendFunc.dst = ccMacros.CC_BLEND_DST; // double retain to avoid the autorelease pool // also, using: self.textureAtlas supports re-initialization without leaking this.m_pTextureAtlas = new CCTextureAtlas(); this.m_pTextureAtlas.initWithFile(tile, itemsToRender); if (m_pTextureAtlas == null) { CCLog.Log("cocos2d: Could not initialize CCAtlasNode. Invalid Texture."); return(false); } this.updateBlendFunc(); this.updateOpacityModifyRGB(); this.calculateMaxItems(); m_uQuadsToDraw = itemsToRender; return(true); }
/// <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 textureAtlasWithFile(string file, int capacity) { CCTextureAtlas pTextureAtlas = new CCTextureAtlas(); if (pTextureAtlas.initWithFile(file, capacity)) { return pTextureAtlas; } return null; }
public static CCTextureAtlas textureAtlasWithTexture(CCTexture2D texture, int capacity) { CCTextureAtlas cCTextureAtla = new CCTextureAtlas(); if (cCTextureAtla.initWithTexture(texture, capacity)) { return(cCTextureAtla); } return(null); }
public static CCTextureAtlas textureAtlasWithFile(string file, int capacity) { CCTextureAtlas cCTextureAtla = new CCTextureAtlas(); if (cCTextureAtla.initWithFile(file, capacity)) { return(cCTextureAtla); } return(null); }
public void removeQuadAtIndex(int index) { ccV3F_C4B_T2F_Quad[] ccV3FC4BT2FQuadArray = new ccV3F_C4B_T2F_Quad[this.m_uCapacity]; Array.Copy(this.m_pQuads, ccV3FC4BT2FQuadArray, index); Array.Copy(this.m_pQuads, index + 1, ccV3FC4BT2FQuadArray, index, this.m_uTotalQuads - index - 1); this.m_pQuads = ccV3FC4BT2FQuadArray; CCTextureAtlas mUTotalQuads = this; mUTotalQuads.m_uTotalQuads = mUTotalQuads.m_uTotalQuads - 1; }
/// <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 textureAtlasWithTexture(CCTexture2D texture, int capacity) { CCTextureAtlas pTextureAtlas = new CCTextureAtlas(); if (pTextureAtlas.initWithTexture(texture, capacity)) { return(pTextureAtlas); } return(null); }
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); }
public void insertQuad(ccV3F_C4B_T2F_Quad quad, int index) { CCTextureAtlas mUTotalQuads = this; mUTotalQuads.m_uTotalQuads = mUTotalQuads.m_uTotalQuads + 1; int num = this.m_uTotalQuads - 1 - index; if (num > 0) { Array.Copy(this.m_pQuads, index, this.m_pQuads, index + 1, num); } this.m_pQuads[index] = quad; this.m_bDirty = true; }
public void useSelfRender() { this.m_uAtlasIndex = ccMacros.CCSpriteIndexNotInitialized; this.m_bUseBatchNode = false; this.m_pobTextureAtlas = null; this.m_pobBatchNode = null; this.m_bDirty = this.m_bRecursiveDirty = false; float x = 0f + this.m_obOffsetPositionInPixels.x; float y = 0f + this.m_obOffsetPositionInPixels.y; float num3 = x + this.m_obRectInPixels.size.width; float num4 = y + this.m_obRectInPixels.size.height; this.m_sQuad.bl.vertices = ccTypes.vertex3(x, y, 0f); this.m_sQuad.br.vertices = ccTypes.vertex3(num3, y, 0f); this.m_sQuad.tl.vertices = ccTypes.vertex3(x, num4, 0f); this.m_sQuad.tr.vertices = ccTypes.vertex3(num3, num4, 0f); }
/// <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); }
/// <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(Texture 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.ContentSize; // no lazy alloc in this node Children = new List <Node>(); m_pobDescendants = new List <CCSprite>(); return(true); }
/// <summary> /// tell the sprite to use self-render. /// @since v0.99.0 /// </summary> public void useSelfRender() { m_uAtlasIndex = ccMacros.CCSpriteIndexNotInitialized; m_bUseBatchNode = false; m_pobTextureAtlas = null; m_pobBatchNode = null; m_bDirty = m_bRecursiveDirty = false; float x1 = 0 + m_obOffsetPositionInPixels.x; float y1 = 0 + m_obOffsetPositionInPixels.y; float x2 = x1 + m_obRectInPixels.size.width; float y2 = y1 + m_obRectInPixels.size.height; m_sQuad.bl.vertices = ccTypes.vertex3(x1, y1, 0); m_sQuad.br.vertices = ccTypes.vertex3(x2, y1, 0); m_sQuad.tl.vertices = ccTypes.vertex3(x1, y2, 0); m_sQuad.tr.vertices = ccTypes.vertex3(x2, y2, 0); }
public Atlas1() { m_textureAtlas = CCTextureAtlas.textureAtlasWithFile(TestResource.s_AtlasTest, 3); //m_textureAtlas.retain(); CCSize s = CCDirector.sharedDirector().getWinSize(); // // 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); //} }
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); } }
/// <summary> /// tell the sprite to use self-render. /// @since v0.99.0 /// </summary> public void useSelfRender() { m_uAtlasIndex = ccMacros.CCSpriteIndexNotInitialized; m_bUseBatchNode = false; m_pobTextureAtlas = null; m_pobBatchNode = null; m_bDirty = m_bRecursiveDirty = false; float x1 = 0 + m_obOffsetPositionInPixels.X; float y1 = 0 + m_obOffsetPositionInPixels.Y; float x2 = x1 + m_obRectInPixels.Size.Width; float y2 = y1 + m_obRectInPixels.Size.Height; m_sQuad.bl.vertices = ccTypes.vertex3(x1, y1, 0); m_sQuad.br.vertices = ccTypes.vertex3(x2, y1, 0); m_sQuad.tl.vertices = ccTypes.vertex3(x1, y2, 0); m_sQuad.tr.vertices = ccTypes.vertex3(x2, y2, 0); }
/// <summary> /// tell the sprite to use batch node render. /// @since v0.99.0 /// </summary> public void useBatchNode(CCSpriteBatchNode batchNode) { m_bUseBatchNode = true; m_pobTextureAtlas = batchNode.TextureAtlas; // weak ref m_pobBatchNode = batchNode; }
public bool InitWithTexture(CCTexture2D tex, int capacity) { m_blendFunc.Source = CCMacros.CCDefaultSourceBlending; m_blendFunc.Destination = CCMacros.CCDefaultDestinationBlending; 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 RawList<CCNode>(capacity); m_pobDescendants = new RawList<CCSprite>(capacity); return true; }
/// <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 textureAtlasWithTexture(Texture texture, int capacity) { CCTextureAtlas pTextureAtlas = new CCTextureAtlas(); if (pTextureAtlas.initWithTexture(texture, capacity)) { return pTextureAtlas; } return null; }
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; }
/// <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; }
public void useBatchNode(CCSpriteBatchNode batchNode) { this.m_bUseBatchNode = true; this.m_pobTextureAtlas = batchNode.TextureAtlas; this.m_pobBatchNode = batchNode; }
/// <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> /// initializes an CCAtlasNode with an Atlas file the width and height of each item and the quantity of items to render /// </summary> public bool initWithTileFile(string tile, int tileWidth, int tileHeight, int itemsToRender) { Debug.Assert(tile != null); m_uItemWidth = tileWidth; m_uItemHeight = tileHeight; m_cOpacity = 255; m_tColor = m_tColorUnmodified = ccTypes.ccWHITE; m_bIsOpacityModifyRGB = true; m_tBlendFunc.src = ccMacros.CC_BLEND_SRC; m_tBlendFunc.dst = ccMacros.CC_BLEND_DST; // double retain to avoid the autorelease pool // also, using: self.textureAtlas supports re-initialization without leaking this.m_pTextureAtlas = new CCTextureAtlas(); this.m_pTextureAtlas.initWithFile(tile, itemsToRender); if (m_pTextureAtlas == null) { Debug.WriteLine("cocos2d: Could not initialize CCAtlasNode. Invalid Texture."); return false; } this.updateBlendFunc(); this.updateOpacityModifyRGB(); this.calculateMaxItems(); m_uQuadsToDraw = itemsToRender; return true; }
/// <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; }