public override void NeedsLayout()
        {
            if (null == _thumbSprite || null == _backgroundSprite || null == _progressSprite)
            {
                return;
            }
            // Update thumb position for new value
            float percent = (_value - _minimumValue) / (_maximumValue - _minimumValue);

            CCPoint pos = _thumbSprite.Position;

            pos.X = percent * _backgroundSprite.ContentSize.Width;
            _thumbSprite.Position = pos;

            // Stretches content proportional to newLevel
            CCRect textureRect = _progressSprite.TextureRect;

            textureRect = new CCRect(textureRect.Origin.X, textureRect.Origin.Y, pos.X, textureRect.Size.Height);
            _progressSprite.SetTextureRect(textureRect, _progressSprite.IsTextureRectRotated, textureRect.Size);
        }
Beispiel #2
0
        private CCSprite ReusedTileWithRect(CCRect rect)
        {
            if (m_pReusedTile == null)
            {
                m_pReusedTile = new CCSprite();
                m_pReusedTile.InitWithTexture(m_pobTextureAtlas.Texture, rect, false);
                m_pReusedTile.BatchNode = this;
            }
            else
            {
                // XXX HACK: Needed because if "batch node" is nil,
                // then the Sprite'squad will be reset
                m_pReusedTile.BatchNode = null;

                // Re-init the sprite
                m_pReusedTile.SetTextureRect(rect, false, rect.Size);

                // restore the batch node
                m_pReusedTile.BatchNode = this;
            }

            return(m_pReusedTile);
        }