init
This commit is contained in:
73
Classes/Games/ZJH/ZJH_ChipNode.cpp
Normal file
73
Classes/Games/ZJH/ZJH_ChipNode.cpp
Normal file
@@ -0,0 +1,73 @@
|
||||
|
||||
#include "ZJH_ChipNode.h"
|
||||
|
||||
#include "cocostudio/CocoStudio.h"
|
||||
using namespace cocostudio;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
ZJHChipNode::ZJHChipNode() : _panelRoot(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
ZJHChipNode:: ~ZJHChipNode()
|
||||
{
|
||||
}
|
||||
|
||||
ZJHChipNode* ZJHChipNode::create(uint8 cbCardData)
|
||||
{
|
||||
ZJHChipNode *pRet = new ZJHChipNode();
|
||||
if (pRet && pRet->init(cbCardData))
|
||||
{
|
||||
pRet->autorelease();
|
||||
return pRet;
|
||||
}
|
||||
CC_SAFE_DELETE(pRet);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool ZJHChipNode::init(uint8 cbCardData)
|
||||
{
|
||||
if (!Node::init())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//加载界面数据;
|
||||
_panelRoot = CSLoader::createNode("Games/ZJH/ChipNode.csb");
|
||||
this->addChild(_panelRoot);
|
||||
|
||||
this->ignoreAnchorPointForPosition(false);
|
||||
this->setAnchorPoint(Vec2::ZERO);
|
||||
this->setContentSize(_panelRoot->getContentSize());
|
||||
|
||||
//绑定界面元素;
|
||||
_sprChipBg = static_cast<Sprite*>(_panelRoot->getChildByName("imgChipBg"));
|
||||
CC_ASSERT(_sprChipBg != nullptr);
|
||||
|
||||
//数值;
|
||||
_txtNum = static_cast<Text*>(_panelRoot->getChildByName("txtNum"));
|
||||
CC_ASSERT(_txtNum != nullptr);
|
||||
|
||||
if (cbCardData > 1 && cbCardData <= 5)
|
||||
{
|
||||
_sprChipBg->setTexture(StringUtils::format("Games/ZJH/Table/imgChip%d.png", cbCardData));
|
||||
_txtNum->setString(StringUtils::format("%d", cbCardData));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ZJHChipNode::onEnter()
|
||||
{
|
||||
Node::onEnter();
|
||||
}
|
||||
|
||||
void ZJHChipNode::onExit()
|
||||
{
|
||||
Node::onExit();
|
||||
}
|
||||
|
||||
void ZJHChipNode::onEnterTransitionDidFinish()
|
||||
{
|
||||
Node::onEnterTransitionDidFinish();
|
||||
}
|
||||
Reference in New Issue
Block a user