本文整理汇总了C++中DrawNode::drawSolidRect方法的典型用法代码示例。如果您正苦于以下问题:C++ DrawNode::drawSolidRect方法的具体用法?C++ DrawNode::drawSolidRect怎么用?C++ DrawNode::drawSolidRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DrawNode
的用法示例。
在下文中一共展示了DrawNode::drawSolidRect方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addMapBg
void GameLayer::addMapBg()
{
float width = _visibleSize.width;
DrawNode *mapBg = DrawNode::create();
mapBg->drawSolidRect( Vec2::ZERO , Vec2(width, width), Color4F(Color3B(190,173,158)));
mapBg->setAnchorPoint(Vec2::ZERO);
this->addChild(mapBg);
Vec2 mapOrigin = mapBg->getPosition();
float gap = width/33;
float tileWidth = (width-5*gap)/4;
g_tileSize = tileWidth;
g_mapBg = mapBg;
g_gap = gap;
for(int i = 0; i < MAP_SIZE; i++)
{
for(int j = 0; j < MAP_SIZE; j++)
{
DrawNode* tileBg = DrawNode::create();
tileBg->drawSolidRect(Vec2::ZERO, Vec2(tileWidth, tileWidth) , Color4F( Color3B(208,193,179) ));
tileBg->setPositionX((j+1)*gap+ j*tileWidth);
tileBg->setPositionY((i+1)*gap+ i*tileWidth);
_map->setTilePos(3-i, j, tileBg->getPosition() + Vec2(g_tileSize/2 , g_tileSize/2));
mapBg->addChild(tileBg);
}
}
_map->initStart2();
}
示例2: initUI
void HelloWorldScene::initUI()
{
_gameView = Sprite::create();
_gameView->setPosition(Vec2(20.0f, 20.0f));
// DrawNode* gameViewNode = DrawNode::create();
// gameViewNode->drawSegment(Vec2::ZERO, Vec2(600.0f, 0.0f), 1.0f, Color4F::RED);
// gameViewNode->drawSegment(Vec2(600.0f, 0.0f), Vec2(600.0f, 600.0f), 1.0f, Color4F::RED);
// gameViewNode->drawSegment(Vec2(600.0f, 600.0f), Vec2(0.0f, 600.0f), 1.0f, Color4F::RED);
// gameViewNode->drawSegment(Vec2(0.0f, 600.0f), Vec2::ZERO, 1.0f, Color4F::RED);
//_gameView->addChild(gameViewNode);
addChild(_gameView, 0);
_detailView = Sprite::create();
_detailView->setPosition(Vec2(640.0f, 20.0f));
//DrawNode* optionViewNode = DrawNode::create();
//optionViewNode->drawSegment(Vec2::ZERO, Vec2(476.0f, 0.0f), 1.0f, Color4F::RED);
//optionViewNode->drawSegment(Vec2(476.0f, 0.0f), Vec2(476.0f, 600.0f), 1.0f, Color4F::RED);
//optionViewNode->drawSegment(Vec2(476.0f, 600.0f), Vec2(0.0f, 600.0f), 1.0f, Color4F::RED);
//optionViewNode->drawSegment(Vec2(0.0f, 600.0f), Vec2::ZERO, 1.0f, Color4F::RED);
//_optionView->addChild(optionViewNode);
addChild(_detailView, 0);
_uiLayer = Sprite::create();
addChild(_uiLayer, 1);
DrawNode* bgNode = DrawNode::create();
bgNode->drawSolidRect(Vec2::ZERO, Vec2(1136.0f, 20.0f), Color4F::BLACK);
bgNode->drawSolidRect(Vec2::ZERO, Vec2(20.0f, 640.0f), Color4F::BLACK);
bgNode->drawSolidRect(Vec2(620.0f, 0.0f), Vec2(640.0f, 640.0f), Color4F::BLACK);
bgNode->drawSolidRect(Vec2(1116.0f, 0.0f), Vec2(1136.0f, 640.0f), Color4F::BLACK);
bgNode->drawSolidRect(Vec2(0.0f, 620.0f), Vec2(1136.0f, 640.0f), Color4F::BLACK);
addChild(bgNode,2);
_crossHair = Sprite::create();
DrawNode* node = DrawNode::create();
node->drawSegment(Vec2(-7.0f, -7.0f), Vec2(-3.0f, -3.0f), 1.0f, Color4F::MAGENTA);
node->drawSegment(Vec2(7.0f, -7.0f), Vec2(3.0f, -3.0f), 1.0f, Color4F::MAGENTA);
node->drawSegment(Vec2(7.0f, 7.0f), Vec2(3.0f, 3.0f), 1.0f, Color4F::MAGENTA);
node->drawSegment(Vec2(-7.0f, 7.0f), Vec2(-3.0f, 3.0f), 1.0f, Color4F::MAGENTA);
_crossHair->addChild(node);
_crossHair->setPosition(_winSize / 2);
_crossHair->runAction(RepeatForever::create(RotateBy::create(1.0f, 90.0f)));
_uiLayer->addChild(_crossHair);
_worldNode = DrawNode::create();
_gameView->addChild(_worldNode);
_detailNode = DrawNode::create();
_detailView->addChild(_detailNode, 2);
}
示例3: init
bool obj_dialoguer::init() {
if (UObject::init(obj_dialoguer::object_index)) {
removeAllChildren();
CC_SAFE_RELEASE_NULL(_writer);
CC_SAFE_RELEASE_NULL(_face);
_writer = obj_writer::create();
CC_SAFE_RETAIN(_writer);
_writer->setUndertaleFont(2); //generic dialog
Size size(304 - 16, 80 - 5);
setContentSize(size);
DrawNode* box = DrawNode::create(3);
box->drawSolidRect(Vec2(0, 0), size, Color4F::WHITE);
box->drawSolidRect(Vec2(3, 3), size - Size(3, 3), Color4F::BLACK);
// box->drawRect(Vec2(0, 0), Vec2(304 - 16, 80 - 5), Color4F::WHITE);
//box->setPosition(size / 2);
box->setAnchorPoint(Vec2::ZERO);
_writer->setAnchorPoint(Vec2::ZERO);
addChild(box, -100);
addChild(_writer, 100);
_eventDispatcher->addCustomEventListener("obj_writer_halt", [this](EventCustom* e) {
size_t halt = (size_t)e->getUserData();
// if (halt == 1) {
// this->nextDialogLine(); // key press
// }
});
_eventDispatcher->addCustomEventListener("face_change", [this](EventCustom* e) {
size_t new_face = (size_t)e->getUserData();
if (new_face != this->_face_index) {
if (_face) removeChild(_face, true);
addChild(_face = obj_face::create(new_face));
_face->setEmotion(_emotion_index);
reset();
_face_index = new_face;
}
});
_eventDispatcher->addCustomEventListener("emotion_change", [this](EventCustom* e) {
size_t new_emotion = (size_t)e->getUserData();
if (new_emotion != _emotion_index) {
if (_face) _face->setEmotion((size_t)e->getUserData());
_emotion_index = new_emotion;
}
});
return true;
}
return false;
}
示例4: draw
void CEAProgressBar::draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t flags) {
this->removeAllChildren();
DrawNode *pDN = DrawNode::create();
this->addChild(pDN);
Vec2 start = m_customRect.origin;
Vec2 end = Vec2(start.x + m_customRect.size.width, start.y + m_customRect.size.height);
Vec2 percentEnd = Vec2(start.x + m_customRect.size.width * m_percentage, start.y + m_customRect.size.height);
pDN->drawRect(start, end, m_outlineColor);
pDN->drawSolidRect(start, percentEnd, m_fillColor);
}
示例5: addScore
void GameLayer::addScore()
{
// label2048
Label *_2048 = Label::createWithTTF("2048", "fonts/ClearSans-Bold.ttf", _visibleSize.width/5.9);
_2048->setColor(Color3B(121,110,100) );
_2048->setAnchorPoint(Vec2( 0, 0.5 ));
_2048->setPosition(Vec2( 0, _visibleSize.height-_2048->getContentSize().height/2) );
this->addChild(_2048);
// best score
DrawNode *bestscoreback = DrawNode::create();
bestscoreback->drawSolidRect( Vec2(-_visibleSize.width/6 ,-g_tileSize/3), Vec2(_visibleSize.width/6 ,g_tileSize/3), Color4F(Color3B(190,173,158)) );
bestscoreback->setPosition( Vec2(_visibleSize.width - _visibleSize.width/6-10 , _2048->getPositionY()-10 ) );
this->addChild(bestscoreback);
Label *best = Label::createWithTTF("BEST", "fonts/ClearSans-Bold.ttf", _visibleSize.width/25);
best->setColor(Color3B(240,228,216));
best->setPositionY(g_tileSize/6.5 );
bestscoreback->addChild(best);
sprintf(buff, "%d", Score::getInstance()->getTopScore());
bestscore = Label::createWithTTF(buff, "fonts/ClearSans-Bold.ttf", _visibleSize.width/15);
bestscore->setPositionY( -g_tileSize/7.5);
bestscoreback->addChild(bestscore);
//score
DrawNode *scoreback = DrawNode::create();
scoreback->drawSolidRect( Vec2(-_visibleSize.width/6 ,-g_tileSize/3), Vec2(_visibleSize.width/6 ,g_tileSize/3), Color4F(Color3B(190,173,158)) );
scoreback->setPosition( Vec2(_visibleSize.width - _visibleSize.width/6-10 , _2048->getPositionY() - g_tileSize/1 ) );
this->addChild(scoreback);
Label *sco = Label::createWithTTF("SCORE", "fonts/ClearSans-Bold.ttf", _visibleSize.width/25);
sco->setColor(Color3B(240,228,216));
sco->setPositionY(g_tileSize/6.5 );
scoreback->addChild(sco);
sprintf(buff, "%d", 0);
score = Label::createWithTTF(buff, "fonts/ClearSans-Bold.ttf", _visibleSize.width/15);
score->setPositionY( -g_tileSize/7.5);
scoreback->addChild(score);
// new game
DrawNode *newGame = DrawNode::create();
newGame->drawSolidRect( Vec2(-_visibleSize.width/6 ,-g_tileSize/4), Vec2(_visibleSize.width/6 ,g_tileSize/4), Color4F(Color3B(147,122,98)) );
newGame->setPosition( Vec2(_visibleSize.width/5.5 , _2048->getPositionY() - g_tileSize/1 ) );
this->addChild(newGame);
Label *ngame = Label::createWithTTF("New Game", "fonts/ClearSans-Bold.ttf", _visibleSize.width/17);
ngame->setColor(Color3B(250,246,241));
//newGame->addChild(ngame);
// ai
DrawNode *aiback = DrawNode::create();
aiback->drawSolidRect( Vec2(-_visibleSize.width/15 ,-g_tileSize/4), Vec2(_visibleSize.width/15 ,g_tileSize/4), Color4F(Color3B(147,122,98)) );
aiback->setPosition( Vec2(_visibleSize.width/2.3 , _2048->getPositionY() - g_tileSize/1 ) );
this->addChild(aiback);
Label *ai = Label::createWithTTF("AI", "fonts/ClearSans-Bold.ttf", _visibleSize.width/17);
ai->setColor(Color3B(250,246,241));
//aiback->addChild(ai);
MenuItemLabel *newgamelabel = MenuItemLabel::create(ngame, CC_CALLBACK_1(GameLayer::startNewGame, this));
newgamelabel->setPosition(newGame->getPosition());
ailable = MenuItemLabel::create(ai, CC_CALLBACK_1(GameLayer::startAi, this));
ailable->setPosition(aiback->getPosition());
Menu *menu = Menu::create(newgamelabel,ailable, NULL);
menu->setPosition(Vec2::ZERO);
this->addChild(menu);
}
示例6: InitUI
//初始化UI
void UIPublishTaskInfo::InitUI()
{
//加载UI
mLayout = CocosHelper::singleton()->getScaleLayout("CCS_publish_taskInfo.csb", this);
//两个删除按钮
ImageView *image1 = (ImageView*)CocosHelper::getNodeByName(mLayout, "Image_5");
Text *text1 = (Text*)CocosHelper::getNodeByName(mLayout, "Text_4");
Button *btnClose1 = (Button*)CocosHelper::getNodeByName(mLayout, "BtnClose1");
btnClose1->addTouchEventListener
(
[image1, text1, btnClose1](Ref *sender, Widget::TouchEventType type)
{
if(type == Widget::TouchEventType::ENDED)
{
image1->setVisible(false);
text1->setVisible(false);
btnClose1->setVisible(false);
}
}
);
ImageView *image2 = (ImageView*)CocosHelper::getNodeByName(mLayout, "Image_6");
Text *text2 = (Text*)CocosHelper::getNodeByName(mLayout, "Text_5");
Button *btnClose2 = (Button*)CocosHelper::getNodeByName(mLayout, "BtnClose2");
btnClose2->addTouchEventListener
(
[image2, text2, btnClose2](Ref *sender, Widget::TouchEventType type)
{
if(type == Widget::TouchEventType::ENDED)
{
image2->setVisible(false);
text2->setVisible(false);
btnClose2->setVisible(false);
}
}
);
//添加头像按钮
Button *btnAdd = (Button*)CocosHelper::getNodeByName(mLayout, "Button_Add");
btnAdd->addTouchEventListener
(
[this](Ref *sender, Widget::TouchEventType type)
{
if(type == Widget::TouchEventType::ENDED)
{
//this->addChild(UIMediaSelectLayer::create());
UIMediaSelectLayer *select =UIMediaSelectLayer::create();
select->setSelectCallFunc
(
[this](vector<UIImageStruct> files)
{
for(int i=0; i<files.size(); i++)
{
UIImageStruct temp = files.at(i);
this->AddImage(temp.file);
}
}
);
//UIMainLayer::gUIMainLayer->pushLayer(select);
}
}
);
//模特头像
mImageAvatar = ImageView::create();
Layout *modelAvatarPanel = (Layout*)CocosHelper::getNodeByName(mLayout, "Panel_ShenHe");
//模特头像的遮罩
mAvatarClipping = ClippingNode::create();
mAvatarClipping->setPosition(189, 309);
DrawNode *shap = DrawNode::create();
shap->drawSolidRect(Point(0, 0), Point(344, 340), Color4F(0, 0, 0, 0));
shap->setPosition(Vec2(-344*0.5, -170));
mAvatarClipping->setStencil(shap);
mAvatarClipping->setInverted(false);
modelAvatarPanel->addChild(mAvatarClipping);
//mAvatarClipping->addChild(ImageView::create("taskList/Task_0_2.png"));
mAvatarClipping->addChild(mImageAvatar);
}