//
//  Button.cpp
//  Game
//
//  Created by Darvydas on 27/01/2019.
//

#include "Button.hpp"

namespace Game
{
    using namespace cocos2d;
    
    CButton *CButton::create(CAction* pcAction) {
        
        CButton *sp = new CButton;
        
        sp->m_pcAction = pcAction;
        
        if (sp->init()) {
            
            sp->autorelease();
            
            sp->setColor(Color3B::BLACK);
            sp->setOpacity(255 * 0.3f);
            
            sp->createVisualElements();
            
            return sp;
        }
        CC_SAFE_DELETE(sp);
        return NULL;
    }
    
    void CButton::setString(const char* szStr)
    {
        m_pcLabel->setString(szStr);
    }
    
    void CButton::createVisualElements()
    {
        m_pcLabel = cocos2d::Label::createWithTTF("", "arial.ttf", this->getContentSize().height * 0.5f);
        m_pcLabel->setPosition(Point(this->getContentSize().width * 0.5f, this->getContentSize().height * 0.5f));
        
        this->addChild(m_pcLabel, 200);
    }
}





