// display the FPS using a LabelAtlas // updates the FPS every frame private void ShowStats() { m_uFrames++; m_fAccumDt += m_fDeltaTime; if (m_bDisplayStats) { if (m_pFPSLabel != null && m_pSPFLabel != null && m_pDrawsLabel != null) { if (m_fAccumDt > CCMacros.CCDirectorStatsUpdateIntervalInSeconds) { m_pSPFLabel.Label = (String.Format("{0:0.000}", m_fSecondsPerFrame)); m_fFrameRate = m_uFrames / m_fAccumDt; m_uFrames = 0; m_fAccumDt = 0; m_pFPSLabel.Label = (String.Format("{0:00.0}", m_fFrameRate)); m_pDrawsLabel.Label = (String.Format("{0:000}", CCDrawManager.DrawCount)); } m_pDrawsLabel.Visit(); m_pFPSLabel.Visit(); m_pSPFLabel.Visit(); } } }
public void NeedsLayout() { m_pOnSprite.Position = new CCPoint(m_pOnSprite.ContentSize.Width / 2 + m_fSliderXPosition, m_pOnSprite.ContentSize.Height / 2); m_pOffSprite.Position = new CCPoint(m_pOnSprite.ContentSize.Width + m_pOffSprite.ContentSize.Width / 2 + m_fSliderXPosition, m_pOffSprite.ContentSize.Height / 2); m_ThumbSprite.Position = new CCPoint(m_pOnSprite.ContentSize.Width + m_fSliderXPosition, m_pMaskTexture.ContentSize.Height / 2); if (m_pOnLabel != null) { m_pOnLabel.Position = new CCPoint(m_pOnSprite.Position.X - m_ThumbSprite.ContentSize.Width / 6, m_pOnSprite.ContentSize.Height / 2); } if (m_pOffLabel != null) { m_pOffLabel.Position = new CCPoint(m_pOffSprite.Position.X + m_ThumbSprite.ContentSize.Width / 6, m_pOffSprite.ContentSize.Height / 2); } CCRenderTexture rt = new CCRenderTexture((int)m_pMaskTexture.ContentSize.Width, (int)m_pMaskTexture.ContentSize.Height, SurfaceFormat.Color, DepthFormat.None, RenderTargetUsage.DiscardContents); rt.BeginWithClear(0, 0, 0, 0); m_pOnSprite.Visit(); m_pOffSprite.Visit(); if (m_pOnLabel != null) { m_pOnLabel.Visit(); } if (m_pOffLabel != null) { m_pOffLabel.Visit(); } if (m_pMaskSprite == null) { m_pMaskSprite = new CCSprite(m_pMaskTexture); m_pMaskSprite.AnchorPoint = new CCPoint(0, 0); m_pMaskSprite.BlendFunc = new CCBlendFunc(CCOGLES.GL_ZERO, CCOGLES.GL_SRC_ALPHA); } else { m_pMaskSprite.Texture = m_pMaskTexture; } m_pMaskSprite.Visit(); rt.End(); Texture = rt.Sprite.Texture; //IsFlipY = true; }
public void NeedsLayout() { _onSprite.Position = new CCPoint(_onSprite.ContentSize.Width / 2 + _sliderXPosition, _onSprite.ContentSize.Height / 2); _offSprite.Position = new CCPoint(_onSprite.ContentSize.Width + _offSprite.ContentSize.Width / 2 + _sliderXPosition, _offSprite.ContentSize.Height / 2); _thumbSprite.Position = new CCPoint(_onSprite.ContentSize.Width + _sliderXPosition, _maskSprite.ContentSize.Height / 2); if (_onLabel != null) { _onLabel.Position = new CCPoint(_onSprite.Position.X - _thumbSprite.ContentSize.Width / 6, _onSprite.ContentSize.Height / 2); } if (_offLabel != null) { _offLabel.Position = new CCPoint(_offSprite.Position.X + _thumbSprite.ContentSize.Width / 6, _offSprite.ContentSize.Height / 2); } var rt = new CCRenderTexture( (int)_maskSprite.ContentSizeInPixels.Width, (int)_maskSprite.ContentSizeInPixels.Height, SurfaceFormat.Color, DepthFormat.None, RenderTargetUsage.DiscardContents ); rt.BeginWithClear(0, 0, 0, 0); _onSprite.Visit(); _offSprite.Visit(); if (_onLabel != null) { _onLabel.Visit(); } if (_offLabel != null) { _offLabel.Visit(); } _maskSprite.AnchorPoint = new CCPoint(0, 0); _maskSprite.BlendFunc = new CCBlendFunc(CCOGLES.GL_ZERO, CCOGLES.GL_SRC_ALPHA); _maskSprite.Visit(); rt.End(); InitWithTexture(rt.Sprite.Texture); ContentSize = _maskSprite.ContentSize; }