/// <summary> /// initializes a TextureAtlas with a previously initialized Texture2D object, and /// with an initial capacity for Quads. /// The TextureAtlas capacity can be increased in runtime. /// WARNING: Do not reinitialize the TextureAtlas because it will leak memory (issue #706) /// </summary> public bool InitWithTexture(CCTexture2D texture, int capacity) { //Debug.Assert(texture != null); // retained in property m_pTexture = texture; // Re-initialization is not allowed Debug.Assert(m_pQuads == null); if (capacity < 4) { capacity = 4; } m_pVertexBuffer = new CCQuadVertexBuffer(capacity, BufferUsage.WriteOnly); m_pQuads = m_pVertexBuffer.Data; Dirty = true; return(true); }
/* protected override void AddedToScene() { base.AddedToScene(); visibleTileRangeDirty = true; } protected override void VisibleBoundsChanged() { base.VisibleBoundsChanged(); visibleTileRangeDirty = true; } protected override void ParentUpdatedTransform() { base.ParentUpdatedTransform(); visibleTileRangeDirty = true; } */ protected override void Dispose(bool disposing) { if (disposing) { quadsVertexBuffer.Dispose(); indexBuffer.Dispose(); quadsVertexBuffer = null; indexBuffer = null; } base.Dispose (disposing); }
void InitialiseQuadsVertexBuffer() { int numOfQuads = (int)NumberOfTiles * NumOfCornersPerQuad; quadsVertexBuffer = new CCQuadVertexBuffer(numOfQuads, CCBufferUsage.WriteOnly); if (tileSetTexture.ContentSizeInPixels != CCSize.Zero) { for (int y = 0; y < LayerSize.Row; y++) { for (int x = 0; x < LayerSize.Column; x++) { UpdateQuadAt(x, y, false); } } } quadsVertexBuffer.UpdateBuffer(0, numOfQuads); }
public CCTextureAtlas(CCTexture2D texture, int capacity) { Texture = texture; // Re-initialization is not allowed Debug.Assert(Quads == null); if (capacity < 4) { capacity = 4; } vertexBuffer = new CCQuadVertexBuffer(capacity, CCBufferUsage.WriteOnly); Quads = vertexBuffer.Data; Dirty = true; }
/// <summary> /// initializes a TextureAtlas with a previously initialized Texture2D object, and /// with an initial capacity for Quads. /// The TextureAtlas capacity can be increased in runtime. /// WARNING: Do not reinitialize the TextureAtlas because it will leak memory (issue #706) /// </summary> public bool InitWithTexture(CCTexture2D texture, int capacity) { //Debug.Assert(texture != null); // retained in property m_pTexture = texture; // Re-initialization is not allowed Debug.Assert(m_pQuads == null); if (capacity < 4) { capacity = 4; } m_pVertexBuffer = new CCQuadVertexBuffer(capacity, BufferUsage.WriteOnly); m_pQuads = m_pVertexBuffer.Data; Dirty = true; return true; }