本文整理汇总了C++中setContentSize函数的典型用法代码示例。如果您正苦于以下问题:C++ setContentSize函数的具体用法?C++ setContentSize怎么用?C++ setContentSize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setContentSize函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: PhysicsNode
StarPhysicsNode::StarPhysicsNode(const char* f, CCPoint p, AroundMeLayer* layer)
: PhysicsNode(layer) {
m_image = QString(f);
b2BodyDef bd;
bd.type = b2_dynamicBody;
bd.position.Set(p.x / PTM_RATIO, p.y / PTM_RATIO);
bd.userData = this;
b2Body *body = m_world->CreateBody(&bd);
b2Vec2 vertices[3];
{
b2PolygonShape triangle;
vertices[0] = b2Vec2(-3.0f, 0.78f);
vertices[1] = b2Vec2(-1.98f, -0.84f);
vertices[2] = b2Vec2(-1.2f, 1.56f);
triangle.Set(vertices, 3);
b2FixtureDef fixtureDef;
fixtureDef.shape = ▵
fixtureDef.density = 1.0f;
fixtureDef.restitution = 0.5;
fixtureDef.friction = 0.3f;
fixtureDef.filter.categoryBits = CHEERIOS;
body->CreateFixture(&fixtureDef);
}
{
b2PolygonShape triangle;
vertices[0] = b2Vec2(-1.2f, 1.56f);
vertices[1] = b2Vec2(1.2f, 1.56f);
vertices[2] = b2Vec2(0.0f, 3.0f);
triangle.Set(vertices, 3);
b2FixtureDef fixtureDef;
fixtureDef.shape = ▵
fixtureDef.density = 1.0f;
fixtureDef.restitution = 0.5;
fixtureDef.friction = 0.3f;
fixtureDef.filter.categoryBits = CHEERIOS;
body->CreateFixture(&fixtureDef);
}
{
b2PolygonShape triangle;
vertices[0] = b2Vec2(1.2f, 1.56f);
vertices[1] = b2Vec2(1.98f, -0.84f);
vertices[2] = b2Vec2(3.0f, 0.78f);
triangle.Set(vertices, 3);
b2FixtureDef fixtureDef;
fixtureDef.shape = ▵
fixtureDef.density = 1.0f;
fixtureDef.restitution = 0.5;
fixtureDef.friction = 0.3f;
fixtureDef.filter.categoryBits = CHEERIOS;
body->CreateFixture(&fixtureDef);
}
{
b2PolygonShape triangle;
vertices[0] = b2Vec2(1.98f, -0.84f);
vertices[1] = b2Vec2(0.0f, -2.22f);
vertices[2] = b2Vec2(1.8f, -3.0f);
triangle.Set(vertices, 3);
b2FixtureDef fixtureDef;
fixtureDef.shape = ▵
fixtureDef.density = 1.0f;
fixtureDef.restitution = 0.5;
fixtureDef.friction = 0.3f;
fixtureDef.filter.categoryBits = CHEERIOS;
body->CreateFixture(&fixtureDef);
}
{
b2PolygonShape triangle;
vertices[0] = b2Vec2(0.0f, -2.22f);
vertices[1] = b2Vec2(-1.98f, -0.84f);
vertices[2] = b2Vec2(-1.8f, -3.0f);
triangle.Set(vertices, 3);
b2FixtureDef fixtureDef;
fixtureDef.shape = ▵
fixtureDef.density = 1.0f;
fixtureDef.restitution = 0.5;
fixtureDef.friction = 0.3f;
fixtureDef.filter.categoryBits = CHEERIOS;
body->CreateFixture(&fixtureDef);
}
{
b2Vec2 vertices[5];
b2PolygonShape pentagon;
vertices[0] = b2Vec2(-1.98f, -0.84f);
vertices[1] = b2Vec2(0.0f, -2.22f);
vertices[2] = b2Vec2(1.98f, -0.84f);
vertices[3] = b2Vec2(1.2f, 1.56f);
vertices[4] = b2Vec2(-1.2f, 1.56f);
pentagon.Set(vertices, 5);
b2FixtureDef fixtureDef;
fixtureDef.shape = &pentagon;
fixtureDef.density = 1.0f;
fixtureDef.restitution = 0.5;
fixtureDef.friction = 0.3f;
fixtureDef.filter.categoryBits = CHEERIOS;
body->CreateFixture(&fixtureDef);
}
setContentSize(CCSize(WORLD_TO_SCREEN(3*2), WORLD_TO_SCREEN(3*2)));
setScale(WORLD_TO_SCREEN(3) / 100);
//.........这里部分代码省略.........
开发者ID:Jon-Joshua,项目名称:BB10,代码行数:101,代码来源:StarPhysicsNode.cpp
示例2: setIsHDPanel
bool RepayView::init(){
if (!PopupBaseView::init()) {
return false;
}
setIsHDPanel(true);
CCLoadSprite::doResourceByCommonIndex(8, true);
CCLoadSprite::doResourceByCommonIndex(11, true);
CCLoadSprite::doResourceByCommonIndex(101, true);
CCLoadSprite::doResourceByCommonIndex(305, true);
CCLoadSprite::doResourceByCommonIndex(502, true);
setCleanFunction([](){
CCLoadSprite::doResourceByCommonIndex(8, false);
CCLoadSprite::doResourceByCommonIndex(11, false);
CCLoadSprite::doResourceByCommonIndex(101, false);
CCLoadSprite::doResourceByCommonIndex(305, false);
CCLoadSprite::doResourceByCommonIndex(502, false);
CCLoadSprite::releaseDynamicResourceByType(CCLoadSpriteType_GOODS);
});
m_dataCount = RepayController::getInstance()->repayRewards.size();
setTitleName("");
auto tmpCCB = CCBLoadFile("RepayView",this,this);
setContentSize(tmpCCB->getContentSize());
auto size = CCDirector::sharedDirector()->getWinSize();
float extH = getExtendHeight();
float add = size.height - 852;
if (CCCommonUtils::isIosAndroidPad()) {
add = size.height - 2048;
add = add / 2.4;
}
m_bgNode->setPositionY(m_bgNode->getPositionY()-extH);
auto tbg = CCLoadSprite::loadResource("Bottom frame04.png");
auto tBatchNode = CCSpriteBatchNode::createWithTexture(tbg->getTexture());
int maxHight = ceil(size.height*1.0/90);
for (int j = 0; j<maxHight; j++)
{
for (int i=0; i<8; i++) {
auto bg = CCLoadSprite::createSprite("Bottom frame04.png");
bg->setAnchorPoint(ccp(0, 0));
bg->setPosition(ccp(i*90, j*90));
tBatchNode->addChild(bg);
}
}
m_bgNode->addChild(tBatchNode);
CCSize nodeRewardSize = m_nodeRewards->getContentSize();
nodeRewardSize.height += extH;
m_nodeRewards->setContentSize(nodeRewardSize);
m_nodeRewards->setPositionY(m_nodeRewards->getPositionY()-extH);
m_tabRewards = CCTableView::create(this, nodeRewardSize);
m_tabRewards->setDirection(kCCScrollViewDirectionVertical);
m_tabRewards->setVerticalFillOrder(kCCTableViewFillTopDown);
m_tabRewards->setTouchPriority(Touch_Default);
m_tabRewards->setDelegate(this);
m_nodeRewards->addChild(m_tabRewards);
// m_scrollPoints = CCScrollView::create(m_nodePoints->getContentSize());
// m_scrollPoints->setDirection(kCCScrollViewDirectionHorizontal);
// m_scrollPoints->setTouchEnabled(false);
// m_nodePoints->addChild(m_scrollPoints);
// m_scrollPoints->setPosition(ccp(0, 0));
auto clipNode = CCClipNode::create(m_nodePoints->getContentSize().width, m_nodePoints->getContentSize().height);
clipNode->setAnchorPoint(CCPointZero);
m_nodePoints->addChild(clipNode);
clipNode->setTag(REPAY_CLIP_NODE_TAG);
CCNode *node = CCNode::create();
clipNode->addChild(node);
node->setTag(REPAY_CLIP_NODE_TAG);
auto clipNode1 = CCClipNode::create(m_nodePoints->getContentSize().width - 45, m_nodePoints->getContentSize().height);
m_nodePoints->addChild(clipNode1);
clipNode1->setPosition(ccp(23,0));
clipNode1->setTag(REPAY_CLIP_NODE_BAR_TAG);
auto progress = CCLoadSprite::createScale9Sprite("01_03.png");
progress->setAnchorPoint(ccp(0, 0.5));
progress->setTag(REPAY_CLIP_NODE_BAR_TAG);
clipNode1->addChild(progress);
progress->setPreferredSize(CCSize(1, 26));
progress->setPosition(ccp(2.5, 60));
// setTitleName(_lang("133246"));
m_lblTitle->setString(_lang("101100"));//距离累计充值大反馈结束还有
// setButtonTitle(m_btnGoBuy, _lang("101221").c_str());
m_lblPointTitle->setString(_lang("133247"));
m_lblRewardTitle->setString(_lang("105848"));
m_lblPointOrgW = m_lblPointTitle->getContentSize().width * m_lblPointTitle->getOriginScaleX();
m_lblPointOrgX = m_lblPointTitle->getPositionX();
onTimer(0);
this->schedule(schedule_selector(RepayView::onTimer),1.0);
initPointNode(true);
CCPoint offset = m_tabRewards->getContentOffset();
int newPoint = RepayController::getInstance()->getNewPayPoint();
int lv = RepayController::getInstance()->getLVIndexByPoint(newPoint) - 3;
float changeH = 0;
while (lv>-1) {
changeH += tableCellSizeForIndex(m_tabRewards, lv).height;
lv--;
}
offset.y += changeH;
m_tabRewards->setContentOffset(offset);
return true;
}
开发者ID:ourgames,项目名称:dc208,代码行数:100,代码来源:RepayView.cpp
示例3: Window
EditServerDialog::EditServerDialog(ServerDialog *parent, ServerInfo server,
int index) :
Window(_("Edit Server"), true, parent),
mServerDialog(parent),
mServer(server),
mIndex(index)
{
setWindowName("EditServerDialog");
Label *nameLabel = new Label(_("Name:"));
Label *serverAdressLabel = new Label(_("Address:"));
Label *portLabel = new Label(_("Port:"));
Label *typeLabel = new Label(_("Server type:"));
Label *descriptionLabel = new Label(_("Description:"));
mServerAddressField = new TextField(std::string());
mPortField = new TextField(std::string());
mPortField->setNumeric(true);
mPortField->setRange(1, 65535);
mTypeListModel = new TypeListModel();
mTypeField = new DropDown(mTypeListModel);
mTypeField->setSelected(0); // TmwAthena by default for now.
mNameField = new TextField(std::string());
mDescriptionField = new TextField(std::string());
mOkButton = new Button(_("OK"), "addServer", this);
mCancelButton = new Button(_("Cancel"), "cancel", this);
mServerAddressField->addActionListener(this);
mPortField->addActionListener(this);
place(0, 0, nameLabel);
place(1, 0, mNameField, 4).setPadding(3);
place(0, 1, serverAdressLabel);
place(1, 1, mServerAddressField, 4).setPadding(3);
place(0, 2, portLabel);
place(1, 2, mPortField, 4).setPadding(3);
place(0, 3, typeLabel);
place(1, 3, mTypeField).setPadding(3);
place(0, 4, descriptionLabel);
place(1, 4, mDescriptionField, 4).setPadding(3);
place(4, 5, mOkButton);
place(3, 5, mCancelButton);
// Do this manually instead of calling reflowLayout so we can enforce a
// minimum width.
int width = 0, height = 0;
getLayout().reflow(width, height);
if (width < 300)
{
width = 300;
getLayout().reflow(width, height);
}
if (height < 120)
{
height = 120;
getLayout().reflow(width, height);
}
setContentSize(width, height);
setMinWidth(getWidth());
setMinHeight(getHeight());
setDefaultSize(getWidth(), getHeight(), ImageRect::CENTER);
setResizable(false);
addKeyListener(this);
loadWindowState();
mNameField->setText(mServer.name);
mDescriptionField->setText(mServer.description);
mServerAddressField->setText(mServer.hostname);
mPortField->setText(toString(mServer.port));
switch (mServer.type)
{
#ifdef EATHENA_SUPPORT
case ServerInfo::EATHENA:
mTypeField->setSelected(2);
break;
case ServerInfo::MANASERV:
#ifdef MANASERV_SUPPORT
mTypeField->setSelected(3);
break;
#endif
#else
case ServerInfo::MANASERV:
#ifdef MANASERV_SUPPORT
mTypeField->setSelected(2);
break;
#endif
#endif
default:
case ServerInfo::UNKNOWN:
case ServerInfo::TMWATHENA:
mTypeField->setSelected(0);
break;
case ServerInfo::EVOL:
//.........这里部分代码省略.........
开发者ID:EvolOnline,项目名称:ManaPlus,代码行数:101,代码来源:editserverdialog.cpp
示例4: Size
bool TestController::init() {
Layer::init();
Sprite *hello = Sprite::create("HelloWorld.png");
hello->setPosition(Vec2(240, 160));
this->addChild(hello);
std::string text = std::string() +
"Police have said they plan" +
"to dismantle the camp of colorful" +
"tents and art installations Thursday" +
"morning, urging protesters to leave" +
"peacefully."+ "On Thursday morning," +
"bailiffs read out the court injunction," +
"telling demonstrators to pack up and" +
"leave on their own accord. They then"
"began dismantling and removing barricades"
"at the far western end of the protest area." +
"The bailiffs carried off metal and plastic" +
"barriers that had been lashed together, as" +
"well as broken umbrellas -- wilted versions" +
"of the protest movement's symbol.";
textLabel = Label::createWithTTF(text,
"fonts/Skranji-Regular.ttf",
24);
textLabel->setAnchorPoint(Vec2(0, 1));
textLabel->setPosition(Vec2(0, 300));
textLabel->setDimensions(300, 500);
textLabel->setAlignment(TextHAlignment::LEFT, TextVAlignment::TOP);
// textLabel->enableOutline(Color4B(52, 26, 7, 255), 1);
textLabel->enableShadow(Color4B(52, 26, 7, 255), Size(-0.5f, -0.5f));
// this->addChild(textLabel);
CCLOG("content size = (%f, %f)", textLabel->getContentSize().width,
textLabel->getContentSize().height);
auto clipper = ClippingNode::create();
clipper->setTag( 98 );
clipper->setContentSize( Size(300, 300) );
clipper->setAnchorPoint( Vec2(0.5, 0.5) );
clipper->setPosition(this->getContentSize().width / 2, this->getContentSize().height / 2);
// clipper->runAction(RepeatForever::create(RotateBy::create(1, 45)));
this->addChild(clipper);
auto stencil = DrawNode::create();
Vec2 rectangle[4];
rectangle[0] = Vec2(0, 0);
rectangle[1] = Vec2(clipper->getContentSize().width, 0);
rectangle[2] = Vec2(clipper->getContentSize().width, clipper->getContentSize().height);
rectangle[3] = Vec2(0, clipper->getContentSize().height);
Color4F white(1, 1, 1, 1);
stencil->drawPolygon(rectangle, 4, white, 1, white);
clipper->setStencil(stencil);
// auto content = Sprite::create();
// content->setContentSize(Size(300, 300));
// content->setTag( 97 );
// content->setAnchorPoint( Vec2(0.5, 0.5) );
// content->setPosition(clipper->getContentSize().width / 2, clipper->getContentSize().height / 2);
clipper->addChild(textLabel);
// content->addChild(textLabel);
auto listener = EventListenerTouchOneByOne::create();
listener->setSwallowTouches(true);
listener->onTouchBegan = CC_CALLBACK_2(TestController::onTouchBegan, this);
listener->onTouchMoved = CC_CALLBACK_2(TestController::onTouchMoved, this);
listener->onTouchEnded = CC_CALLBACK_2(TestController::onTouchEnded, this);
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
return true;
}
开发者ID:bacnd,项目名称:Cocos2dx-V3-Game,代码行数:76,代码来源:WordLayer.cpp
示例5: setContentSize
void CCClippingRegionNode::setClippingRegion(const CCRect &clippingRegion)
{
m_clippingRegion = clippingRegion;
setContentSize(clippingRegion.size);
}
开发者ID:Ratel13,项目名称:quick-cocos2d-x,代码行数:5,代码来源:CCClippingRegionNode.cpp
示例6: if
void SportsLayer::Shieldtouched(){
//事件
auto listen=EventListenerTouchOneByOne::create();
listen->setSwallowTouches(true);//设置不想向下传递触摸 true是不想 默认为false
listen->onTouchBegan = [this](Touch* touch, Event* event){
m_touchPoint = Director::getInstance()->convertToGL(touch->getLocationInView());
return true;
};
listen->onTouchMoved = [this](Touch* touch, Event* event){
};
listen->onTouchEnded = [this](Touch* touch, Event* event){
Vec2 endPoint = Director::getInstance()->convertToGL(touch->getLocationInView());
if(endPoint.x>=this->getPositionX()-getContentSize().width/2&&endPoint.x<=this->getPositionX()+getContentSize().width/2){
float distance = endPoint.x - m_touchPoint.x;
if (fabs(distance) > 50){
float width=Actual_x*0.8f;
float hight=Actual_y*0.8f;
if(vsion==1){
width=Actual_x*0.8f;
hight=Actual_y*0.8f;
}else if(vsion==2){
width=525;
hight=450;
}
Size visibaleSize = Size(width,hight);
if (distance < 0)
{
m_curPage++;
}else{
m_curPage--;
}
if (m_curPage < 1)
{
m_curPage = 1;
}
if (m_curPage > 2)
{
m_curPage = 2;
}
Vec2 origin = Director::getInstance()->getVisibleOrigin();
Vec2 adjustPos =Vec2(origin.x - (m_curPage - 1) * visibaleSize.width,0);
scrollView->setContentOffset(adjustPos,true);
if(m_curPage>1){
jt1->setVisible(true);
jt2->setVisible(false);
if(vsion==2)
b_label->setString(FX::StringsMap::getValue("dfljing"));
}else if(m_curPage<2){
jt1->setVisible(false);
jt2->setVisible(true);
if(vsion==2)
b_label->setString(FX::StringsMap::getValue("wdfzsm"));
}
}
}
};
EventDispatcher* dispatch=Director::getInstance()->getEventDispatcher();
dispatch->addEventListenerWithSceneGraphPriority(listen,this);
//
ignoreAnchorPointForPosition(false);
setAnchorPoint(Vec2(0.5,0.5));
setPosition(Vec2(Actual_x/2,Actual_y/2));
setContentSize(Size(Actual_x,Actual_y));
}
开发者ID:SongCF,项目名称:game-CoolRun,代码行数:90,代码来源:SportsLayer.cpp
示例7: round
// on "init" you need to initialize your instance
bool LearnScene::init()
{
if ( !LayerColor::initWithColor(Constants::BACKGROUND_COLOR) )
{
return false;
}
Size visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
// Home btn
auto btn = ui::Button::create("HomeBtn", "HomeBtn", "", ui::Widget::TextureResType::PLIST);
btn->setAnchorPoint(Vec2::ANCHOR_TOP_RIGHT);
btn->setPosition(Vec2(origin.x + visibleSize.width, origin.y + visibleSize.height));
btn->addTouchEventListener(CC_CALLBACK_2(LearnScene::touchEvent, this));
this->addChild(btn, 1, 1);
// Learn progress txt
float retainedPercent = round(Constants::getRetainedWordCount() * 100 / Constants::getTotalWordCount());
std::stringstream stm;
stm << "Learning progress: " << retainedPercent << "%";
auto label = Label::createWithBMFont(Constants::FONT_BOLD12, stm.str());
label->setColor(Color3B::BLACK);
label->setAnchorPoint(Vec2::ANCHOR_MIDDLE_LEFT);
label->setPosition(origin.x + 14, origin.y + visibleSize.height - 28);
this->addChild(label, 2, 2);
// Learn progress bar
auto sprite9 = ui::Scale9Sprite::createWithSpriteFrameName("PbBg", Rect(2, 2, 2, 2));
sprite9->setContentSize(Size(visibleSize.width - 28, 18));
sprite9->setPosition(Vec2(origin.x + visibleSize.width/2, origin.y + visibleSize.height - 60));
this->addChild(sprite9, 3, 3);
auto pb = ui::Scale9Sprite::createWithSpriteFrameName("PbProgress", Rect(2, 2, 2, 2));
Size pbSize = sprite9->getContentSize();
pbSize.width *= retainedPercent / 100;
if(pbSize.width < 6) pbSize.width = 6;
pb->setContentSize(pbSize);
pb->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
sprite9->addChild(pb, 1, 1);
// Text area
sprite9 = ui::Scale9Sprite::createWithSpriteFrameName("TextArea", Rect(12, 12, 12, 12));
sprite9->setContentSize(Size(visibleSize.width-28, visibleSize.height - 264));
sprite9->setPosition(Vec2(origin.x + visibleSize.width/2, origin.y + visibleSize.height - 86 - sprite9->getContentSize().height / 2));
this->addChild(sprite9, 4, 4);
// choices
btn = ui::Button::create("ChoiceBg", "ChoiceSelectedBg", "", ui::Widget::TextureResType::PLIST);
btn->setScale9Enabled(true);
btn->setCapInsets(Rect(5, 5, 5, 5));
btn->setSize(Size(visibleSize.width-28, 30));
btn->setPosition(Vec2(origin.x + visibleSize.width/2, origin.y + 148));
btn->getTitleRenderer()->setBMFontFilePath(Constants::FONT_REGULAR12);
btn->getTitleRenderer()->setColor(Color3B::BLACK);
btn->setTitleText("I know this word.");
btn->addTouchEventListener(CC_CALLBACK_2(LearnScene::touchEvent, this));
this->addChild(btn, 5, 5);
btn = ui::Button::create("ChoiceBg", "ChoiceSelectedBg", "", ui::Widget::TextureResType::PLIST);
btn->setScale9Enabled(true);
btn->setCapInsets(Rect(5, 5, 5, 5));
btn->setSize(Size(visibleSize.width-28, 30));
btn->setPosition(Vec2(origin.x + visibleSize.width/2, origin.y + 103));
btn->getTitleRenderer()->setBMFontFilePath(Constants::FONT_REGULAR12);
btn->getTitleRenderer()->setColor(Color3B::BLACK);
btn->setTitleText("Not yet!");
btn->addTouchEventListener(CC_CALLBACK_2(LearnScene::touchEvent, this));
this->addChild(btn, 6, 6);
// check btn
btn = ui::Button::create("BtnNormal", "BtnPressed", "BtnDisabled", ui::Widget::TextureResType::PLIST);
btn->setScale9Enabled(true);
btn->setCapInsets(Rect(12, 12, 12, 12));
btn->setSize(Size(visibleSize.width-28, 58));
btn->setPosition(Vec2(origin.x + visibleSize.width/2, origin.y + 45));
btn->getTitleRenderer()->setBMFontFilePath(Constants::FONT_BOLD30);
btn->setTitleText("Check");
btn->addTouchEventListener(CC_CALLBACK_2(LearnScene::touchEvent, this));
this->addChild(btn, 7, 7);
btn->setEnabled(false);
btn->setBright(false);
// term
std::string nextWord = Constants::getNextWordToLearn();
label = Label::createWithBMFont(Constants::FONT_BOLD30, nextWord);
label->setColor(Color3B::BLACK);
label->setPosition(sprite9->getContentSize().width/2, sprite9->getContentSize().height/2);
sprite9->addChild(label, 1, 1);
// definition
const ValueMap& wInfo = Configuration::getInstance()->getValue("words").asValueMap().at(nextWord).asValueMap();
auto it = wInfo.find("ldef");
std::string ldef = it != wInfo.end() ? it->second.asString() : "Missing definition";
label = Label::createWithBMFont(Constants::FONT_REGULAR14, ldef);
label->setColor(Color3B::BLACK);
label->setWidth(sprite9->getContentSize().width - 28);
label->setAlignment(TextHAlignment::LEFT);
label->setPosition(sprite9->getContentSize().width/2, sprite9->getContentSize().height/2);
sprite9->addChild(label, 2, 2);
//.........这里部分代码省略.........
开发者ID:atapie,项目名称:gre-hit-parade,代码行数:101,代码来源:LearnScene.cpp
示例8: CC_CALLBACK_1
bool HelloWorld::init()
{
if ( !Layer::init() )
{
return false;
}
CReadFile::getInstance()->init();
Size visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
auto closeItem = MenuItemImage::create(
"picture/blue1_menu.png",
"picture/blue2_menu.png"
, CC_CALLBACK_1(HelloWorld::menuCloseCallback, this));
closeItem->setScale(0.3f);
closeItem->setPosition(Vec2(origin.x + visibleSize.width - closeItem->getContentSize().width/2-310 ,
origin.y + closeItem->getContentSize().height/2+160));
auto closeItem1 = MenuItemImage::create(
"picture/blue1_menu.png",
"picture/blue2_menu.png",
CC_CALLBACK_1(HelloWorld::menuCloseCallback1, this));
closeItem1->setScale(0.5f);
closeItem1->setPosition(Vec2(origin.x + visibleSize.width - closeItem1->getContentSize().width/2-310 ,
origin.y + closeItem1->getContentSize().height/2+330));
auto SetMenu = MenuItemImage::create(
"picture/shezhi2_cover.png",
"picture/shezhi1_cover.png",
CC_CALLBACK_1(HelloWorld::menuCloseCallback3, this));
SetMenu->setScale(0.8f);
SetMenu->setPosition(Vec2(origin.x + visibleSize.width - SetMenu->getContentSize().width/2-390 ,
origin.y + SetMenu->getContentSize().height/2+260));
auto menu = Menu::create(closeItem,closeItem1,SetMenu, NULL);
menu->setPosition(Vec2::ZERO);
this->addChild(menu, 1);
#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
auto label = Label::createWithTTF(Tools::Unicode2Utf8(L"开始游戏"), "fonts/msyh.ttc", 24);
#else
auto label = Label::createWithTTF("开始游戏", "fonts/msyh.ttc", 24);
#endif
label->setPosition(Vec2(closeItem1->getPositionX(), closeItem1->getPositionY()));
label->setScale(0.8f);
this->addChild(label, 1);
#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
auto label1 = Label::createWithTTF(Tools::Unicode2Utf8(L"退出"), "fonts/msyh.ttc", 24);
#else
auto label1 = Label::createWithTTF("退出", "fonts/msyh.ttc", 24);
#endif
label1->setPosition(Vec2(closeItem->getPositionX(), closeItem->getPositionY()));
label1->setScale(0.8f);
this->addChild(label1,1);
auto sprite = Sprite::create("picture/shumabaobei.jpg");
Size sprSize = sprite->getContentSize();
sprite->setScaleX(visibleSize.width/sprSize.width);
sprite->setScaleY(visibleSize.height/sprSize.height);
sprite->setPosition(Vec2(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
this->addChild(sprite, 0);
auto logo = Sprite::create("picture/logo.png");
Size logoSize = logo->getContentSize();
auto spark = Sprite::create("picture/spark.png");
spark->setPosition(-logoSize.width,0);
auto clippingNode = ClippingNode::create();
clippingNode->setPosition(500,560);
this->addChild(clippingNode);
clippingNode->setAlphaThreshold(0.05f);
clippingNode->setContentSize(logoSize);
clippingNode->setStencil(logo);
clippingNode->addChild(logo,1);
clippingNode->addChild(spark,2);
auto moveAction = MoveTo::create(2.0f,Vec2(logoSize.width,0));
auto moveBackAction = MoveTo::create(2.0f,Vec2(-logoSize.width,0));
spark->runAction(RepeatForever::create(Sequence::create(moveAction,moveBackAction,NULL)));
if (CReadFile::getInstance()->getshuomingkg())
{
CReadFile::getInstance()->setshuomingkg(false);
CSound::getInstance()->playBG("Butter-Fly.mp3",CSound::getInstance()->getIsPlay());
CSound::getInstance()->setIsPlay(true);
auto shuominglayer = LayerColor::create(Color4B(120,120,120,200));
#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
auto wenzi = Label::createWithTTF(Tools::Unicode2Utf8(L"欢迎来到宝库设计的数码宝贝记忆消除游戏"),"fonts/msyh.ttc", 28);
#else
auto wenzi = Label::createWithTTF("欢迎来到宝库设计的数码宝贝记忆消除游戏","fonts/msyh.ttc", 28);
#endif
//.........这里部分代码省略.........
开发者ID:wangbaoku,项目名称:test2,代码行数:101,代码来源:HelloWorldScene.cpp
示例9: CCAssert
bool CCTMXTiledMap::initWithTMXFile(const char *tmxFile)
{
CCAssert(tmxFile != NULL && strlen(tmxFile)>0, "TMXTiledMap: tmx file should not bi nil");
setContentSize(CCSizeZero);
CCTMXMapInfo *mapInfo = CCTMXMapInfo::formatWithTMXFile(tmxFile);
if (! mapInfo)
{
return false;
}
CCAssert( mapInfo->getTilesets()->count() != 0, "TMXTiledMap: Map not found. Please check the filename.");
m_tMapSize = mapInfo->getMapSize();
m_tTileSize = mapInfo->getTileSize();
m_nMapOrientation = mapInfo->getOrientation();
setObjectGroups(mapInfo->getObjectGroups());
setProperties(mapInfo->getProperties());
CC_SAFE_RELEASE(m_pTileProperties);
m_pTileProperties = mapInfo->getTileProperties();
CC_SAFE_RETAIN(m_pTileProperties);
int idx = 0;
CCMutableArray<CCTMXLayerInfo*>* layers = mapInfo->getLayers();
if (layers && layers->count()>0)
{
if (NULL == m_pTMXLayers)
{
m_pTMXLayers = new CCDictionary<std::string, CCTMXLayer*>();
CCAssert(m_pTMXLayers, "Allocate memory failed!");
}
CCTMXLayerInfo *layerInfo = NULL;
CCMutableArray<CCTMXLayerInfo*>::CCMutableArrayIterator it;
for (it = layers->begin(); it != layers->end(); ++it)
{
layerInfo = *it;
if (layerInfo && layerInfo->m_bVisible)
{
CCTMXLayer *child = parseLayer(layerInfo, mapInfo);
addChild((CCNode*)child, idx, idx);
// record the CCTMXLayer object by it's name
std::string layerName = child->getLayerName();
m_pTMXLayers->setObject(child, layerName);
// update content size with the max size
const CCSize& childSize = child->getContentSize();
CCSize currentSize = this->getContentSize();
currentSize.width = MAX( currentSize.width, childSize.width );
currentSize.height = MAX( currentSize.height, childSize.height );
this->setContentSize(currentSize);
idx++;
}
}
}
return true;
}
开发者ID:Bahamut,项目名称:cocos2d-x,代码行数:61,代码来源:CCTMXTiledMap.cpp
示例10: rect
//.........这里部分代码省略.........
boundsRect.origin.y = -y;
}
if (boundsRect.size.height < -y)
{
boundsRect.size.height = -y;
}
}
boundsRect.size.width -= boundsRect.origin.x;
boundsRect.size.height -= boundsRect.origin.y;
for (std::size_t i = 0, l = this->_meshData->vertexIndices.size(); i < l; ++i)
{
vertexIndices[i] = this->_meshData->vertexIndices[i];
}
// In cocos2dx render meshDisplay and frameDisplay are the same display
frameDisplay->setSpriteFrame(currentTextureData->texture); // polygonInfo will be override
if (currentTexture != currentTextureData->texture->getTexture())
{
frameDisplay->setTexture(currentTexture); // Relpace texture // polygonInfo will be override
}
//
cocos2d::PolygonInfo polygonInfo;
auto& triangles = polygonInfo.triangles;
triangles.verts = displayVertices;
triangles.indices = vertexIndices;
triangles.vertCount = (unsigned)(this->_meshData->uvs.size() / 2);
triangles.indexCount = (unsigned)(this->_meshData->vertexIndices.size());
polygonInfo.rect = boundsRect; // Copy
frameDisplay->setPolygonInfo(polygonInfo);
frameDisplay->setContentSize(boundsRect.size);
if (this->_meshData->skinned)
{
frameDisplay->setScale(1.f, 1.f);
frameDisplay->setRotationSkewX(0.f);
frameDisplay->setRotationSkewY(0.f);
frameDisplay->setPosition(0.f, 0.f);
}
frameDisplay->setAnchorPoint(cocos2d::Vec2::ZERO);
}
else
{
cocos2d::Vec2 pivot(currentDisplayData->pivot.x, currentDisplayData->pivot.y);
const auto& rectData = currentTextureData->frame ? *currentTextureData->frame : currentTextureData->region;
auto width = rectData.width;
auto height = rectData.height;
if (!currentTextureData->frame && currentTextureData->rotated)
{
width = rectData.height;
height = rectData.width;
}
if (currentDisplayData->isRelativePivot)
{
pivot.x *= width;
pivot.y *= height;
}
if (currentTextureData->frame)
{
开发者ID:xiajiaonly,项目名称:DragonBonesCPP,代码行数:67,代码来源:CCSlot.cpp
示例11: boundsRect
//.........这里部分代码省略.........
const auto& boneIndices = this->_meshData->boneIndices[iH];
const auto& boneVertices = this->_meshData->boneVertices[iH];
const auto& weights = this->_meshData->weights[iH];
float xG = 0.f, yG = 0.f;
for (std::size_t iB = 0, lB = boneIndices.size(); iB < lB; ++iB)
{
const auto bone = this->_meshBones[boneIndices[iB]];
const auto matrix = bone->globalTransformMatrix;
const auto weight = weights[iB];
float xL = 0.f, yL = 0.f;
if (hasFFD)
{
xL = boneVertices[iB * 2] + this->_ffdVertices[iF];
yL = boneVertices[iB * 2 + 1] + this->_ffdVertices[iF + 1];
}
else
{
xL = boneVertices[iB * 2];
yL = boneVertices[iB * 2 + 1];
}
xG += (matrix->a * xL + matrix->c * yL + matrix->tx) * weight;
yG += (matrix->b * xL + matrix->d * yL + matrix->ty) * weight;
iF += 2;
}
auto& vertices = displayVertices[iH];
auto& vertex = vertices.vertices;
vertex.set(xG, -yG, 0.f);
if (boundsRect.origin.x > xG)
{
boundsRect.origin.x = xG;
}
if (boundsRect.size.width < xG)
{
boundsRect.size.width = xG;
}
if (boundsRect.origin.y > -yG)
{
boundsRect.origin.y = -yG;
}
if (boundsRect.size.height < -yG)
{
boundsRect.size.height = -yG;
}
}
}
else if (hasFFD)
{
const auto& vertices = _meshData->vertices;
for (std::size_t i = 0, l = this->_meshData->vertices.size(); i < l; i += 2)
{
const auto iH = unsigned(i / 2);
const auto xG = vertices[i] + _ffdVertices[i];
const auto yG = vertices[i + 1] + _ffdVertices[i + 1];
auto& vertices = displayVertices[iH];
auto& vertex = vertices.vertices;
vertex.set(xG, -yG, 0.f);
if (boundsRect.origin.x > xG)
{
boundsRect.origin.x = xG;
}
if (boundsRect.size.width < xG)
{
boundsRect.size.width = xG;
}
if (boundsRect.origin.y > -yG)
{
boundsRect.origin.y = -yG;
}
if (boundsRect.size.height < -yG)
{
boundsRect.size.height = -yG;
}
}
}
boundsRect.size.width -= boundsRect.origin.x;
boundsRect.size.height -= boundsRect.origin.y;
cocos2d::Rect* rect = (cocos2d::Rect*)&meshDisplay->getPolygonInfo().rect;
rect->origin = boundsRect.origin; // copy
rect->size = boundsRect.size; // copy
meshDisplay->setContentSize(boundsRect.size);
}
开发者ID:xiajiaonly,项目名称:DragonBonesCPP,代码行数:101,代码来源:CCSlot.cpp
示例12: setContentSize
bool FloorMapLayer::init(int floor)
{
_floor = floor;
// 由于直接继承自node,需要做一些处理,现在layer的功能全被废弃了,无意义
setContentSize(Director::getInstance()->getWinSize());
auto listener = EventListenerTouchOneByOne::create();
listener->setSwallowTouches(true);
listener->onTouchBegan = CC_CALLBACK_2(FloorMapLayer::onTouchBegan, this);
listener->onTouchEnded = CC_CALLBACK_2(FloorMapLayer::onTouchEnded, this);
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
// 加载地图编辑器文件
auto res = "TileMaps/floor00" + String::createWithFormat("%d", floor)->_string + ".tmx";
_tiled_map = cocos2d::experimental::TMXTiledMap::create(res);
if (nullptr != _tiled_map)
{
_tiled_map->setPosition(Vec2(-50.0f, -50.0f));
this->addChild(_tiled_map);
}
// 路径节点
_road_node = Node::create();
if (nullptr != _road_node)
{
_road_node->setPosition(Vec2::ZERO);
this->addChild(_road_node);
}
// 勇士骨骼动画节点
_warrior = WarriorNode::create();
/*cocostudio::CCBone* bone = _warrior->getBone("sheild1");
int index = bone->getDisplayManager()->getCurrentDisplayIndex();
bone->removeDisplay(1);
bone->changeDisplayByIndex(-1, true);
cocostudio::CCBone* bone2 = _warrior->getBone("sheild2");
index = bone2->getDisplayManager()->getCurrentDisplayIndex();
bone2->removeDisplay(1);
bone2->changeDisplayByIndex(-1, true);*/
_warrior->setPosition(Vec2(62.5f, 62.5f));
this->addChild(_warrior);
// 上方背景
auto inside_bg = Sprite::create("Images/bg_top2.png");
auto outside_bg = Sprite::create("Images/bg_top_1.png");
if (nullptr != outside_bg && nullptr != inside_bg)
{
auto win_size = Director::getInstance()->getWinSize();
outside_bg->setScale(inside_bg->getContentSize().width / outside_bg->getContentSize().width);
outside_bg->setPosition(Vec2(win_size.width / 2, 1092.0f));
this->addChild(outside_bg);
inside_bg->setPosition(Vec2(win_size.width / 2, 1076.0f));
this->addChild(inside_bg);
}
// 点击箭头节点
_arrow_node = ArrowNode::create();
if (nullptr != _arrow_node)
{
_arrow_node->setPosition(Vec2::ZERO);
_arrow_node->setVisible(false);
this->addChild(_arrow_node);
}
// 勇士属性面板
_info_panel = WarriorInfoPanel::create();
if (nullptr != _info_panel)
{
_info_panel->setPosition(Vec2(-10.0f, 825.0f));
this->addChild(_info_panel);
}
return true;
}
开发者ID:anarki1234,项目名称:mota,代码行数:75,代码来源:FloorMapLayer.cpp
示例13: Window
ServerDialog::ServerDialog(ServerInfo *const serverInfo,
const std::string &dir) :
// TRANSLATORS: servers dialog name
Window(_("Choose Your Server"), Modal_false, nullptr, "server.xml"),
ActionListener(),
KeyListener(),
SelectionListener(),
mMutex(),
mServers(ServerInfos()),
mDir(dir),
mDescription(new Label(this, std::string())),
// TRANSLATORS: servers dialog button
mQuitButton(new Button(this, _("Quit"), "quit", this)),
// TRANSLATORS: servers dialog button
mConnectButton(new Button(this, _("Connect"), "connect", this)),
// TRANSLATORS: servers dialog button
mAddEntryButton(new Button(this, _("Add"), "addEntry", this)),
// TRANSLATORS: servers dialog button
mEditEntryButton(new Button(this, _("Edit"), "editEntry", this)),
// TRANSLATORS: servers dialog button
mDeleteButton(new Button(this, _("Delete"), "remove", this)),
// TRANSLATORS: servers dialog button
mLoadButton(new Button(this, _("Load"), "load", this)),
mServersListModel(new ServersListModel(&mServers, this)),
mServersList(new ServersListBox(this, mServersListModel)),
mDownload(nullptr),
mServerInfo(serverInfo),
mPersistentIPCheckBox(nullptr),
mDownloadProgress(-1.0F),
mDownloadStatus(DOWNLOADING_UNKNOWN)
{
mServersList->postInit();
if (isSafeMode)
{
// TRANSLATORS: servers dialog name
setCaption(_("Choose Your Server *** SAFE MODE ***"));
}
setWindowName("ServerDialog");
setCloseButton(true);
mPersistentIPCheckBox = new CheckBox(this,
// TRANSLATORS: servers dialog checkbox
_("Use same ip for game sub servers"),
config.getBoolValue("usePersistentIP"),
this, "persitent ip");
loadCustomServers();
mServersList->addMouseListener(this);
ScrollArea *const usedScroll = new ScrollArea(this, mServersList,
getOptionBool("showbackground"), "server_background.xml");
usedScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
mServersList->addSelectionListener(this);
usedScroll->setVerticalScrollAmount(0);
place(0, 0, usedScroll, 7, 5).setPadding(3);
place(0, 5, mDescription, 7);
place(0, 6, mPersistentIPCheckBox, 7);
place(0, 7, mAddEntryButton);
place(1, 7, mEditEntryButton);
place(2, 7, mLoadButton);
place(3, 7, mDeleteButton);
place(5, 7, mQuitButton);
place(6, 7, mConnectButton);
// Make sure the list has enough height
getLayout().setRowHeight(0, 80);
// Do this manually instead of calling reflowLayout so we can enforce a
// minimum width.
int width = 500;
int height = 350;
getLayout().reflow(width, height);
setContentSize(width, height);
setMinWidth(310);
setMinHeight(220);
setDefaultSize(getWidth(), getHeight(), ImageRect::CENTER);
setResizable(true);
addKeyListener(this);
loadWindowState();
}
开发者ID:nashley,项目名称:ManaPlus,代码行数:90,代码来源:serverdialog.cpp
示例14: setContentSize
bool Layer::init()
{
Director * director = Director::getInstance();
setContentSize(director->getWinSize());
return true;
}
开发者ID:1007650105,项目名称:Cocos2dxDrawingArtifacts,代码行数:6,代码来源:CCLayer.cpp
示例15: setIsHDPanel
bool PropSpeedupView::init(int type,int bid, int qid){
if (!PopupBaseView::init()) {
return false;
}
setIsHDPanel(true);
bool bRet=false;
// CCLoadSprite::doResourceByCommonIndex(11, true);
CCLoadSprite::doResourceByWorldIndex(2, true);
setCleanFunction([](){
// CCLoadSprite::doResourceByCommonIndex(11, false);
CCLoadSprite::doResourceByWorldIndex(2, false);
CCLoadSprite::releaseDynamicResourceByType(CCLoadSpriteType_GOODS);
});
if (CCBLoadFile("PropSpeedupView.ccbi", this, this)) {
this->getAnimationManager()->runAnimationsForSequenceNamed("stop");
CCSize size=CCDirector::sharedDirector()->getWinSize();
setContentSize(size);
m_proptype = type,
m_qID = qid;
m_buildingID = bid;
CCSize nodeSize = m_nodeProp1->getContentSize();
m_scrollView = CCScrollView::create(nodeSize);
m_scrollView->setDirection(kCCScrollViewDirectionHorizontal);
m_scrollView->setTouchEnabled(false);
//m_scrollView->setDelegate(this);
m_nodeProp1->addChild(m_scrollView);
m_lblInfo->setString(_lang("102358").c_str());
switch (m_proptype) {
case ItemSpdMenu_Soldier:{ //造兵
|
请发表评论