예제 #1
0
파일: Slider.cpp 프로젝트: 54993306/Classes
void CSlider::onTouchCancelled(CCTouch *pTouch, float fDuration)
{
	if( m_bDrag )
	{
		changeValueAndExecuteEvent(valueFromPoint(convertToNodeSpace(pTouch->getLocation())), true);
	}
}
예제 #2
0
void CProgressBar::setDirection(CProgressBarDirection eDirection)
{
	if( m_eDirection != eDirection )
	{
		m_eDirection = eDirection;
		changeValueAndExecuteEvent(m_nValue, false);
	}
}
예제 #3
0
void CProgressBar::setContentSize(const CCSize& tSize)
{
	CCNodeRGBA::setContentSize(tSize);

	m_tCenterPoint.x = m_obContentSize.width / 2;
	m_tCenterPoint.y = m_obContentSize.height / 2;

	if( m_pProgressSprite )
	{
		changeValueAndExecuteEvent(m_nValue, false);
	}

	CC_WIDGET_UPDATE_BACKGROUND_POS;
}
예제 #4
0
파일: ProgressBar.cpp 프로젝트: Kudoo/Tui-x
void CProgressBar::setValue(int nValue)
{
	changeValueAndExecuteEvent(nValue, true);

	if(getLabel()->isVisible()){
		char buf[128] = {0};
		switch (m_eLabelFormat)
		{
		case kRatio:	
			sprintf(buf,"%d/%d",nValue,m_nMaxValue);	
			break;
		case kPercent:	
			sprintf(buf,"%.1f%%",nValue/m_nMaxValue);	
			break;
		}
		getLabel()->setString(buf);
	}
}
예제 #5
0
파일: Slider.cpp 프로젝트: 54993306/Classes
CWidgetTouchModel CSlider::onTouchBegan(CCTouch *pTouch)
{
	if (!m_bDragable)
	{
		return eWidgetTouchNone;
	}

	m_bDrag = m_pSlider->boundingBox().containsPoint(
		convertToNodeSpace(pTouch->getLocation())
	);

	if( m_bDrag )
	{
		changeValueAndExecuteEvent(valueFromPoint(convertToNodeSpace(pTouch->getLocation())), true);
		return eWidgetTouchSustained;
	}

	return eWidgetTouchNone;
}
예제 #6
0
void CProgressBar::setProgressSpriteFrame(CCSpriteFrame* pFrame)
{
	if( pFrame )
	{
		if( m_pProgressSprite )
		{
			m_pProgressSprite->setDisplayFrame(pFrame);
			m_tProgressSize = m_pProgressSprite->getContentSize();
			setContentSize(m_tProgressSize);
		}
		else
		{
			m_pProgressSprite = CCSprite::createWithSpriteFrame(pFrame);
			m_pProgressSprite->setZOrder(1);

			m_tProgressSize = m_pProgressSprite->getContentSize();
			setContentSize(m_tProgressSize);
			addChild(m_pProgressSprite);
		}
		changeValueAndExecuteEvent(m_nValue, false);
	}
}
예제 #7
0
void CProgressBar::onProgressing(float dt)
{
	if( isProgressEnded() )
	{
		stoppedProgressing();
		executeProgressEndedHandler(this);
	}
	else
	{
		if( m_bFirstTick )
		{
			m_bFirstTick = false;
			m_fLapsed = 0.0f;
		}
		else
		{
			m_fLapsed += CCDirector::sharedDirector()->getDeltaTime();
		}

		float fTime = MAX(0, MIN(1, m_fLapsed / MAX(m_fDuration, FLT_EPSILON)));
		changeValueAndExecuteEvent(m_nFromValue + (m_nToValue - m_nFromValue) * fTime, true);
	}
}
예제 #8
0
void CProgressBar::setProgressTexture(CCTexture2D* pTexture)
{
	if( m_pProgressSprite )
	{
		m_pProgressSprite->setTexture(pTexture);

		CCRect tRect = CCRectZero;
		tRect.size = pTexture->getContentSize();
		m_pProgressSprite->setTextureRect(tRect);

		m_tProgressSize = pTexture->getContentSize();
		setContentSize(m_tProgressSize);
	}
	else
	{
		m_pProgressSprite = CCSprite::createWithTexture(pTexture);
		m_pProgressSprite->setZOrder(1);

		m_tProgressSize = m_pProgressSprite->getContentSize();
		setContentSize(m_tProgressSize);
		addChild(m_pProgressSprite);
	}
	changeValueAndExecuteEvent(m_nValue, false);
}
예제 #9
0
void CProgressBar::startProgressFromTo(int nFromValue, int nToValue, float fDuration)
{
	changeValueAndExecuteEvent(nFromValue, true);
	startProgress(nToValue, fDuration);
}
예제 #10
0
void CProgressBar::setValue(int nValue)
{
	changeValueAndExecuteEvent(nValue, true);
}