|
//实现倒计时
this->_down_Label =CCLabelTTF::create();
CCString* downStr = CCString::createWithFormat("%d",this->_dowmTime);
this->_down_Label->setString(downStr->m_sString.c_str());
this->addChild(this->_down_Label,3);
this->_down_Label->setPosition(ccp(this->_shootCard->getPosition().x,this->_shootCard->getPosition().y));
this->_down_Label->setFontSize(30);
//更新倒计时 void GameLayer::downTime(float dt)
{
this->_dowmTime =this->_dowmTime -1;
CCString* downStr = CCString::createWithFormat("%d",this->_dowmTime);
this->_down_Label->setString(downStr->m_sString.c_str());
}
schedule(schedule_selector(GameLayer::downTime),1.0f); |
cocos2d-x 使用schedule实现倒计时
最新推荐文章于 2023-11-28 22:47:46 发布
本文介绍如何在Cocos2d-x中实现倒计时功能,包括创建倒计时标签并更新显示内容。通过调度定时器每秒减少倒计时数值,并更新标签文本。
368

被折叠的 条评论
为什么被折叠?



