代码拉取完成,页面将自动刷新
#include "MagiciteGameCDItem.h"
#include "MagiciteItem.h"
USING_NS_CC;
MagiciteGameCDItem::MagiciteGameCDItem()
:_itemView(nullptr), _cd(0.0f), _is_cd(false)
{
}
MagiciteGameCDItem::~MagiciteGameCDItem()
{
}
void MagiciteGameCDItem::activate()
{
if (_itemView != nullptr)
{
MenuItem::activate();
}
}
void MagiciteGameCDItem::setItemView(MagiciteItem* item)
{
if (item != nullptr)
{
_itemView = item;
item->setPosition(this->getContentSize().width / 2, this->getContentSize().height / 2);
this->addChild(item);
}
}
void MagiciteGameCDItem::eraseItemView()
{
if (_itemView != nullptr)
{
_itemView->removeFromParentAndCleanup(true);
_itemView = nullptr;
_cd = 0.0f;
_is_cd = false;
}
}
bool MagiciteGameCDItem::init()
{
if (!MenuItem::initWithCallback((const ccMenuCallback&)nullptr))
{
return false;
}
auto cd_sprite = Sprite::create("img\\Magicite\\Item\\cd.png");
_cdView = ProgressTimer::create(cd_sprite);
_cdView->setReverseProgress(true);
_cdView->setType(ProgressTimer::Type::RADIAL);
_cdView->setOpacity(180);
_cdView->setVisible(false);
this->addChild(_cdView, 1);
return true;
}
void MagiciteGameCDItem::startCd(float n)
{
if (_is_cd)
{
this->setEnabled(false);
_cdView->setVisible(true);
_cdView->setPosition(Vec2(getContentSize().width / 2, getContentSize().height / 2));
_cdView->setScale(getContentSize().width / 100, getContentSize().height / 100);
auto progressAction = ProgressFromTo::create(n, 0.0f, 100.0f);
auto progressCallback = CallFunc::create([this](){
this->setEnabled(true);
_cdView->setVisible(false);
});
_cdView->runAction(Sequence::create(progressAction, progressCallback, nullptr));
}
}
void MagiciteGameCDItem::setCD(float n)
{
_cd = n;
}
float MagiciteGameCDItem::getCD() const
{
return _cd;
}
void MagiciteGameCDItem::setCDEnable(bool state)
{
_is_cd = state;
}
bool MagiciteGameCDItem::getCdEnable() const
{
return _is_cd;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。