本文整理汇总了C++中CCArmature::getContentSize方法的典型用法代码示例。如果您正苦于以下问题:C++ CCArmature::getContentSize方法的具体用法?C++ CCArmature::getContentSize怎么用?C++ CCArmature::getContentSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCArmature
的用法示例。
在下文中一共展示了CCArmature::getContentSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
// on "init" you need to initialize your instance
bool LayerChatWindow::init()
{
//////////////////////////////
// 1. super init first
if ( !CCLayer::init() )
{
return false;
}
lstStringMessage.clear();
lstStringMessage.push_back("Nhanh lên nào (14)!");
lstStringMessage.push_back("Mạng lag quá (9)!");
lstStringMessage.push_back("Bài xấu quá (3)!");
lstStringMessage.push_back("Hehe, lên nóc nhà\nmà bắt con gà (6)");
lstStringMessage.push_back("Nhất rồi, haha (1)");
lstStringMessage.push_back("Đánh gà thế (11)!");
lstStringMessage.push_back("Đỏ vãi lúa (13)!");
lstStringMessage.push_back("Nhọ như chó mực (5)!");
//return true;
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
_count = 100;
layerButton = UILayer::create();
layerButton->addWidget(GUIReader::shareReader()->widgetFromJsonFile("LayerChatWindow_1.ExportJson"));
this->addChild(layerButton);
layerButton->setTouchPriority(-128);
this->setTouchEnabled(true);
//Get all chat button
for( int i = 1; i <= 8; i++ ){
UIButton* btnChat = dynamic_cast<UIButton*>(layerButton->getWidgetByName( CCString::createWithFormat("btnChat%d", i)->getCString() ));
btnChat->setTitleText( lstStringMessage.at(i-1).c_str() );
btnChat->addTouchEventListener(this,(SEL_TouchEvent)&LayerChatWindow::onButtonChats);
}
UIButton* btnClose = dynamic_cast<UIButton*>(layerButton->getWidgetByName("btnClose"));
btnClose->addTouchEventListener(this,(SEL_TouchEvent)&LayerChatWindow::onButtonClose);
//
UIButton* btnSend = dynamic_cast<UIButton*>(layerButton->getWidgetByName("btnSend"));
btnSend->addTouchEventListener(this,(SEL_TouchEvent)&LayerChatWindow::onButtonSend);
txtChat = dynamic_cast<UITextField*>(layerButton->getWidgetByName("txtChat"));
txtChat->setText("");
txtChat->setPlaceHolder("Noi dung");
txtChat->setTextHorizontalAlignment(kCCTextAlignmentCenter);
txtChat->setTextVerticalAlignment(kCCVerticalTextAlignmentCenter);
txtChat->addEventListenerTextField(this, textfieldeventselector(LayerChatWindow::textFieldEvent));
UIPanel* pEmo = dynamic_cast<UIPanel*>(layerButton->getWidgetByName("pEmo"));
UIImageView* pImg = dynamic_cast<UIImageView*>(layerButton->getWidgetByName("Image_25_0"));
//Add all emo to this
int i = 1;
// CCArmatureDataManager::sharedArmatureDataManager()->removeArmatureFileInfo(CCString::createWithFormat("onion%d.ExportJson", 1)->getCString());
// CCArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo(CCString::createWithFormat("onion%d.ExportJson", 1)->getCString());
int row=-1, col = 1;
int widthOfPage = 580;
int numOfCols = 9;
int space = 10;
int widthOfImage = 50;
int startPosX = widthOfPage/2 - (widthOfImage+space)*numOfCols/2 - 300;
int startPosY = space - 100;
lstEmo.clear();
for( int i = 1; i<=16; i++ ){
CCArmature *armature = CCArmature::create(CCString::createWithFormat("onion%d", 1)->getCString());
armature->getAnimation()->playByIndex(i-1);
RichElementCustomNode* recustom = RichElementCustomNode::create(1, ccWHITE, 255, armature);
RichText* _richText = RichText::create();
_richText->setContentSize( armature->getContentSize() );
_richText->pushBackElement(recustom);
if( col> numOfCols ){
row++;
col = 1;
}
_richText->setAnchorPoint(ccp(0, 1));
_richText->setPosition(ccp( startPosX + 60*(col-1)
, -1*row*50 - startPosY - (row+1)*space ));
_richText->addTouchEventListener(this,(SEL_TouchEvent)&LayerChatWindow::OnEmoClick);
lstEmo.push_back( armature );
UIButton* b = UIButton::create();
b->setPosition(ccp( startPosX + 60*(col-1)
, -1*row*50 - startPosY - (row+1)*space ));
b->setAnchorPoint(ccp(0, 1));
b->setContentSize( armature->getContentSize() );
b->addTouchEventListener(this,(SEL_TouchEvent)&LayerChatWindow::OnEmoClick);
b->loadTextures("emo_blank.png", "", "");
b->setTag(i);
pImg->addChild( _richText );
pImg->addChild( b );
//CCLOG("button w: %lf h: %lf", b->getContentSize().width, b->getContentSize().height);
col++;
}
return true;
}
示例2: update
void GameScene::update(float dt)
{
CCArmature * imManArmature = playLayer->imManArmature;
int actionNum = playLayer->actionNum;
if(actionNum ==playLayer->ACTION_RUN)
{
playLayer->playerBoundingBox = CCRectMake(imManArmature->getPosition().x-imManArmature->getContentSize().width/2+46,imManArmature->getPosition().y,imManArmature->getContentSize().width-90,imManArmature->getContentSize().height-50);
}
else if(actionNum == playLayer->ACTION_STAND_JUMP)
{
playLayer->playerBoundingBox = CCRectMake(imManArmature->getPosition().x-imManArmature->getContentSize().width/2+30,imManArmature->getPosition().y,imManArmature->getContentSize().width-50,imManArmature->getContentSize().height-50);
}
else if(actionNum == playLayer->ACTION_RUN_JUMP)
{
playLayer->playerBoundingBox = CCRectMake(imManArmature->getPosition().x-imManArmature->getContentSize().width/2+33,imManArmature->getPosition().y,imManArmature->getContentSize().width-70,imManArmature->getContentSize().height-50);
}
else if(actionNum == playLayer->ACTION_RUN_STOP)
{
playLayer->playerBoundingBox = CCRectMake(imManArmature->getPosition().x-imManArmature->getContentSize().width/2+40,imManArmature->getPosition().y,imManArmature->getContentSize().width-110,imManArmature->getContentSize().height-45);
}
else if(actionNum == playLayer->ACTION_RUN_ATTACK)
{
playLayer->playerBoundingBox = CCRectMake(imManArmature->getPosition().x-imManArmature->getContentSize().width/2,imManArmature->getPosition().y,imManArmature->getContentSize().width,imManArmature->getContentSize().height);
}
else if(actionNum == playLayer->ACTION_STAND_ATTACK)
{
playLayer->playerBoundingBox = CCRectMake(imManArmature->getPosition().x-imManArmature->getContentSize().width/2,imManArmature->getPosition().y,imManArmature->getContentSize().width,imManArmature->getContentSize().height);
}
else if(actionNum == playLayer->ACTION_DEATH)
{
playLayer->playerBoundingBox = CCRectMake(imManArmature->getPosition().x-imManArmature->getContentSize().width/2,imManArmature->getPosition().y,imManArmature->getContentSize().width,imManArmature->getContentSize().height);
}
if(gameSceneMonster->MonsterIndex == MonsterGround_enum)
{
gameSceneMonster->MonsterAmatureBoundingBox = CCRectMake(gameSceneMonster->MonsterAmature->getPosition().x-gameSceneMonster->MonsterAmature->getContentSize().width/2+45,gameSceneMonster->MonsterAmature->getPosition().y+21,gameSceneMonster->MonsterAmature->getContentSize().width-90,gameSceneMonster->MonsterAmature->getContentSize().height-90);
}
else if(gameSceneMonster->MonsterIndex == MonsterSky_enum)
{
gameSceneMonster->MonsterAmatureBoundingBox = CCRectMake(gameSceneMonster->MonsterAmature->getPosition().x-gameSceneMonster->MonsterAmature->getContentSize().width/2+45,gameSceneMonster->MonsterAmature->getPosition().y+21,gameSceneMonster->MonsterAmature->getContentSize().width-90,gameSceneMonster->MonsterAmature->getContentSize().height-90);
}
if (playLayer->playerBoundingBox.intersectsRect(gameSceneMonster->MonsterAmatureBoundingBox))
{
/*
if(MonsterGround_enum == gameSceneMonster->MonsterIndex)
{
gameSceneMonster->unscheduleUpdate();
gameSceneMonster->MonsterDestroyAction();
}
*/
CCShake * shark = CCShake::create(0.3f,10);
playLayer->runAction(shark);
playLayer->imManArmatureBrood-=1;
if(playLayer->imManArmatureBrood<1)
{
GameScene::shareGameScene()->menuLayer->setBroodBarPercent(0);
this->unscheduleUpdate();
playLayer->IMDeath();
return;
}
GameScene::shareGameScene()->menuLayer->setBroodBarPercent(playLayer->imManArmatureBrood);
}
}