本文整理汇总了C++中DrawNode::drawRect方法的典型用法代码示例。如果您正苦于以下问题:C++ DrawNode::drawRect方法的具体用法?C++ DrawNode::drawRect怎么用?C++ DrawNode::drawRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DrawNode
的用法示例。
在下文中一共展示了DrawNode::drawRect方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addLayer
void RectCollider::addLayer(Layer* layer, int depth) {
DrawNode* node = DrawNode::create();
Vec2 origin = Vec2::ZERO;
Vec2 dest = Vec2::ZERO;
Vec2 cpos = Vec2::ZERO;
if (NULL != this->behaviour) {
BaseRenderAsset* pbra = (BaseRenderAsset*)this->behaviour->getAsset("anime");
Transform transform = pbra->getTransform();
cpos = transform.getPosition().vector2d;
Size allSize = transform.getContentsScale().getAllScale();
Size halfSize = transform.getContentsScale().getHalfScale();
origin = Vec2(-1 * halfSize.width, -1 * halfSize.height);
dest = Vec2(allSize.width, allSize.height);
} else if (NULL != this->node) {
cpos = this->node->position;
Vec2 position = this->node->position;
Scale* scale = this->node->scale;
float width = scale->getHalfScale().width;
float height = scale->getHalfScale().height;
dest = Vec2(width, height);
}
node->drawRect(origin, dest, Color4F(0.0f, 1.0f, 0.0f, 0.5f));
node->setPosition(cpos);
layer->addChild(node, depth);
}
示例2: addChild
bool LayerAnimationPractice04::init()
{
if (!LayerColor::initWithColor(Color4B::GRAY))
{
return false;
}
Size winSize = Director::getInstance()->getWinSize();
Button* pBtnTest = Button::create();
pBtnTest->setTitleFontSize(40.0f);
pBtnTest->setTitleColor(Color3B::BLACK);
pBtnTest->setTitleText("Test");
pBtnTest->setPosition(Vec2(winSize.width*0.5f, 40.0f));
addChild(pBtnTest);
pBtnTest->addClickEventListener(CC_CALLBACK_1(LayerAnimationPractice04::btnTestCallback, this));
m_pNormalItem = NormalItem::create();
m_pNormalItem->setPosition(winSize*0.5f+ITEM_SIZE);
addChild(m_pNormalItem);
for (int i=0; i<10; ++i)
{
DrawNode* pDrawNode = DrawNode::create();
pDrawNode->drawRect(m_pNormalItem->getPosition()-Vec2(0.0f, i*ITEM_SIZE.height),
m_pNormalItem->getPosition()+ITEM_SIZE,
Color4F::RED);
addChild(pDrawNode);
}
return true;
}
示例3: 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);
}
示例4: drawBorder
void GameController::drawBorder(Node* a_node, Color4F a_color4f)
{
float height = a_node->getContentSize().height;
float width = a_node->getContentSize().width;
DrawNode* pDrawNode = DrawNode::create();
pDrawNode->drawRect( Vec2(0.0f, 0.0f), Vec2(width, height), a_color4f);
a_node->addChild(pDrawNode, -1);
}
示例5: init
bool BlockHouse::init()
{
if (!Node::init())
return false;
this->firePoint = Vec2(15.f, 0.f);
DrawNode *drawNode = DrawNode::create();
addChild(drawNode);
drawNode->drawSolidCircle(Vec2::ZERO, 10.f, 2 * M_PI, 64, 1, 1, Color4F::BLUE);
drawNode->drawRect(Vec2(0, -3.f), Vec2(firePoint.x, 3.f), Color4F::BLUE);
setFireable(false);
fireTime = 0;
this->scheduleUpdate();
return true;
}
示例6: updateEmotion
virtual void updateEmotion() override {
// if (_glasses) removeChild(_glasses);
// _glasses = nullptr;
if (_emotion == 99) {
_faceSprite->setUndertaleSprite(1986);
setContentSize(_faceSprite->getContentSize());
if (!_glasses) {
addChild(_glasses = USprite::create(1989),100); // spr_face_torielglasses
_glasses->setPosition(_glasses->getContentSize() / 2);
}
_emotion = 0;
}
else {
switch (_emotion) {
case 0: _faceSprite->setUndertaleSprite(1986); break;
case 1: _faceSprite->setUndertaleSprite(2004); break;
case 2: _faceSprite->setUndertaleSprite(1990); break;
case 3: _faceSprite->setUndertaleSprite(1999); break;
case 4: _faceSprite->setUndertaleSprite(2000); break;
case 6: _faceSprite->setUndertaleSprite(1991); break;
case 7: _faceSprite->setUndertaleSprite(1993); break;
case 8: _faceSprite->setUndertaleSprite(1996); break;
case 9: _faceSprite->setUndertaleSprite(1987); break;
}
}
if (!_body) {
addChild(_body = USprite::create(1985), -100); // "spr_face_torielbody" obj_torface.x + obj_torface.sprite_width / 2 - self.sprite_width / 2;
Size contentSize(_body->getContentSize().width, _body->getContentSize().height + _faceSprite->getContentSize().height+9);
setContentSize(contentSize);
_faceSprite->setPositionY(_faceSprite->getPositionY() + 9);
_body->setPositionY(_body->getPositionY() - 9);
{// test box
DrawNode * debug = DrawNode::create();
Vec2 pos = getContentSize()/2;
debug->drawRect(-pos, pos, Color4F::GREEN);
addChild(debug, 1000);
}
}
}