protected void UpdateQuadFromSprite(CCSprite sprite, int index)
        {
            Debug.Assert(sprite != null, "Argument must be non-NULL");

            while (index >= m_pobTextureAtlas.Capacity || m_pobTextureAtlas.Capacity == m_pobTextureAtlas.TotalQuads)
            {
                IncreaseAtlasCapacity();
            }
            //
            // update the quad directly. Don't add the sprite to the scene graph
            //
            sprite.BatchNode  = this;
            sprite.AtlasIndex = index;

            sprite.Dirty = true;

            // UpdateTransform updates the textureAtlas quad
            sprite.UpdateTransform();
        }
Beispiel #2
0
        //CCSpriteSheet Extension
        //implementation CCSpriteSheet (TMXTiledMapExtension)
        protected void AddQuadFromSprite(CCSprite sprite, int index)
        {
            Debug.Assert(sprite != null, "Argument must be non-NULL");

            while (index >= m_pobTextureAtlas.Capacity || m_pobTextureAtlas.Capacity == m_pobTextureAtlas.TotalQuads)
            {
                IncreaseAtlasCapacity();
            }
            //
            // update the quad directly. Don't add the sprite to the scene graph
            //
            sprite.BatchNode  = this;
            sprite.AtlasIndex = index;

            m_pobTextureAtlas.InsertQuad(ref sprite.m_sQuad, index);

            // XXX: updateTransform will update the textureAtlas too using updateQuad.
            // XXX: so, it should be AFTER the insertQuad
            sprite.Dirty = true;
            sprite.UpdateTransform();
        }
Beispiel #3
0
        private CCSprite UpdateTileForGID(uint gid, CCPoint pos)
        {
            CCRect rect = m_pTileSet.RectForGID(gid);

            rect = new CCRect(rect.Origin.X / m_fContentScaleFactor, rect.Origin.Y / m_fContentScaleFactor, rect.Size.Width / m_fContentScaleFactor,
                              rect.Size.Height / m_fContentScaleFactor);
            var z = (int)(pos.X + pos.Y * m_tLayerSize.Width);

            CCSprite tile = ReusedTileWithRect(rect);

            SetupTileSprite(tile, pos, gid);

            // get atlas index
            int indexForZ = AtlasIndexForExistantZ(z);

            tile.AtlasIndex = indexForZ;
            tile.Dirty      = true;
            tile.UpdateTransform();
            m_pTiles[z] = gid;

            return(tile);
        }
        protected void UpdateQuadFromSprite(CCSprite sprite, int index)
        {
            Debug.Assert(sprite != null, "Argument must be non-NULL");

            while (index >= m_pobTextureAtlas.Capacity || m_pobTextureAtlas.Capacity == m_pobTextureAtlas.TotalQuads)
            {
                IncreaseAtlasCapacity();
            }
            //
            // update the quad directly. Don't add the sprite to the scene graph
            //
            sprite.BatchNode = this;
            sprite.AtlasIndex = index;

            sprite.Dirty = true;

            // UpdateTransform updates the textureAtlas quad
            sprite.UpdateTransform();
        }
        //CCSpriteSheet Extension
        //implementation CCSpriteSheet (TMXTiledMapExtension)
        protected void InsertQuadFromSprite(CCSprite sprite, int index)
        {
            Debug.Assert(sprite != null, "Argument must be non-NULL");

            while (index >= m_pobTextureAtlas.Capacity || m_pobTextureAtlas.Capacity == m_pobTextureAtlas.TotalQuads)
            {
                IncreaseAtlasCapacity();
            }
            //
            // update the quad directly. Don't add the sprite to the scene graph
            //
            sprite.BatchNode = this;
            sprite.AtlasIndex = index;

            m_pobTextureAtlas.InsertQuad(ref sprite.m_sQuad, index);

            // XXX: updateTransform will update the textureAtlas too using updateQuad.
            // XXX: so, it should be AFTER the insertQuad
            sprite.Dirty = true;
            sprite.UpdateTransform();
        }