a24hhsj
9/13/2018 - 1:20 AM

cocos common point

#include "VLoginAdReward.h"
#include "cocostudio/CocoStudio.h"
#include "cocostudio/ActionTimeline/CSLoader.h"

#define TAG_BTN_SIMPLE      (101)
#define TAG_BTN_MIDDLE      (102)
#define TAG_BTN_SENIOR      (103)
#define TAG_BTN_CHANLLENGR  (104)

USING_NS_CC;

LoginAdReward::LoginAdReward():
    mImgScore(nullptr),
    mImgHp(nullptr)
{
}

LoginAdReward::~LoginAdReward()
{
}

bool LoginAdReward::init()
{
    if (!Layer::init())
    {
        return false;
    }

    auto RootNode = CSLoader::createNode("VLoginAdReward.csb");
    Size WinSize = Director::getInstance()->getWinSize();
    RootNode->setPosition(WinSize.width / 2, WinSize.height / 2);
    addChild(RootNode);

    auto panel = (ui::Layout*)RootNode->getChildByName("Panel_1");

    auto btnYes = (ui::Button*)panel->getChildByName("btn_yes");
    btnYes->addClickEventListener(CC_CALLBACK_1(LoginAdReward::onBtnComfirmCallback, this));

    return true;
}

void LoginAdReward::onBtnComfirmCallback(cocos2d::Ref* target)
{
    removeFromParent();
}

#ifndef _VLOGINADREWARD_H_
#define _VLOGINADREWARD_H_

#include "cocos2d.h"
#include "ui/CocosGUI.h"

USING_NS_CC;

class LoginAdReward : public Layer
{
public:
    LoginAdReward();
    ~LoginAdReward();
    CREATE_FUNC(LoginAdReward);

private:
    virtual bool init() override;
    void onBtnComfirmCallback(cocos2d::Ref* target);
};

#endif
//button
void function(void)
{
    //设置是否可用
    mBtnAd->setEnabled(false);
  
    //设置纹理
    mBtnAd->loadTextures("ImageSource/Main/cj.png", "", "",  ui::Widget::TextureResType::PLIST);
  
    //设置三种状态下的纹理
    mBtnAd->loadTextureNormal("ImageSource/Main/sc.png", ui::Widget::TextureResType::PLIST);
    mBtnAd->loadTextureDisabled("ImageSource/Main/cj.png", ui::Widget::TextureResType::PLIST);
}

//定时器
unschedule("countdown");
schedule(CC_CALLBACK_1(VLoginInView::updateCountdown, this), 1.0f, CC_REPEAT_FOREVER, 1.0f, "countdown");

//没帧调用
scheduleUpdate();