当前位置: 首页>>代码示例>>C++>>正文


C++ DrawNode类代码示例

本文整理汇总了C++中DrawNode的典型用法代码示例。如果您正苦于以下问题:C++ DrawNode类的具体用法?C++ DrawNode怎么用?C++ DrawNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DrawNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
开发者ID:ucreates,项目名称:clone_cofc,代码行数:25,代码来源:RectCollider.cpp

示例2: addTalkOther

/**
* その他UI
*/
void HelloWorld::addTalkOther(const std::string& str){
	Size size = Director::getInstance()->getVisibleSize();

	DrawNode* draw = DrawNode::create();

	int originalX = OTHER_TEXT_X;
	int originalY = size.height - (TEXT_H * (index + 1));

	int x = originalX - 10;
	int y = originalY - 60;
	int w = 300;
	int h = 60;

	Vec2 points[] = {
		Vec2(x, y),
		Vec2(x + w, y),
		Vec2(x + w, y + h),
		Vec2(x, y + h),
	};

	this->addChild(draw);
	draw->drawPolygon(points, 4, Color4F(0.5, 0, 0, 1), 1, Color4F(1, 0, 0, 1));

	auto text = Text::create(str, "fronts/arial.ttf", 40);
	text->setTextHorizontalAlignment(TextHAlignment::LEFT);
	text->setAnchorPoint(Point(0.0, 1.0));
	text->setPosition(Point(originalX, originalY));
	text->setColor(Color3B(255, 255, 0));
	this->addChild(text);
	index++;
}
开发者ID:vienbk91,项目名称:testMulti,代码行数:34,代码来源:HelloWorldScene.cpp

示例3: 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;
}
开发者ID:CanFengHome,项目名称:Cocos2dXEffect,代码行数:31,代码来源:LayerAnimationPractice04.cpp

示例4: Vec2

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();
}
开发者ID:tiancode,项目名称:2048-AI,代码行数:31,代码来源:GameLayer.cpp

示例5: glLineWidth

bool CardBase::ccTouchBegan(Touch* touch, Event* event)
{
	glLineWidth(16);
	ccDrawColor4B(255,0,0,255);
	Point vertices[] = { Point(0, 0), Point(50, 50), Point(100, 50), Point(100, 100) };
	ccDrawPoly(vertices, 4, true);

	//glLineWidth(16);
	//ccDrawColor4B(0, 255, 0, 255);
	//ccDrawCircle( VisibleRect::center(), 100, 0, 10, false);

	Size s = getbackGround()->getContentSize();

	DrawNode *draw = DrawNode::create();
	addChild(draw, 10);

	// Draw polygons
	Point points[] = { Point(s.height/4,0), Point(s.width,s.height/5), Point(s.width/3*2,s.height) };
	draw->drawPolygon(points, sizeof(points)/sizeof(points[0]), Color4F(1,0,0,0.5), 0, Color4F(0,0,0,0));

	// Draw segment
	//draw->drawSegment(ccp(20,s.height), ccp(20,s.height/2), 10, ccc4f(0, 1, 0, 0.5));

	//draw->drawSegment(ccp(10,s.height/2), ccp(s.width/2, s.height/2), 40, ccc4f(1, 0, 1, 0.5));

//	this->addChild(shadow);
//	addChild(shadow);

	CCLog("ccTouchBegan");
	return true;
}
开发者ID:pope88,项目名称:ChessCli,代码行数:31,代码来源:CardBase.cpp

示例6: CCLOG

void MainGame::onTouchEnded(Touch* touch, Event* event)
{
    CCLOG("touch ended.");
    
    DrawNode* node = (cocos2d::DrawNode*) this->getChildByTag(100);
    node->clear();
}
开发者ID:kazarus,项目名称:CcDemo,代码行数:7,代码来源:example00001.cpp

示例7: DrawFatSegment

static void DrawFatSegment(cpVect a, cpVect b, cpFloat r, cpSpaceDebugColor outline, cpSpaceDebugColor fill, cpDataPointer data)
{
    const Color4F outlineColor(outline.r, outline.g, outline.b, outline.a);
    DrawNode* drawNode = static_cast<DrawNode*>(data);
    drawNode->drawSegment(PhysicsHelper::cpv2point(a),
                          PhysicsHelper::cpv2point(b),
                          PhysicsHelper::cpfloat2float(r==0 ? 1 : r), outlineColor);
}
开发者ID:114393824,项目名称:Cocos2dxShader,代码行数:8,代码来源:CCPhysicsWorld.cpp

示例8: addUnderline

void ITools::addUnderline(void* vv)
{
    Text* tt = (Text*)vv;
    Color4B color = tt->getTextColor();
    DrawNode* drawLine = DrawNode::create();
    drawLine->drawLine(Vec2(0,0), Vec2(tt->getContentSize().width,0), Color4F((float)color.r/255, (float)color.g/255, (float)color.b/255, (float)color.a/255));
    drawLine->setPosition(Vec2(0,2));
    tt->addChild(drawLine);
}
开发者ID:PinLe2016,项目名称:pinlegame2.2.1,代码行数:9,代码来源:Tools.cpp

示例9: 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);
}
开发者ID:wangbin-git,项目名称:cross-elimination-army,代码行数:10,代码来源:CEAProgressBar.cpp

示例10: Vec2

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);
}
开发者ID:badarmaqsood,项目名称:archer,代码行数:10,代码来源:GameController.cpp

示例11: drawTrail

// 軌跡の描画
void BrushTrail::drawTrail( const Vec2& start, const Vec2& end )
{
	mCanvas->renderingBegin();
	
	DrawNode* drawNode { DrawNode::create() };
	drawNode->drawSegment( start, end, LINE_WIDTH, Color4F::WHITE );
	mCanvas->addRenderingTarget( drawNode );
	
	mCanvas->renderingEnd();
}
开发者ID:CassisOrange,项目名称:TeamProject,代码行数:11,代码来源:BrushTrail.cpp

示例12: TouchPoint

	TouchPoint(const Vec2 &touchPoint, const Color3B &touchColor)
	{
		m_point = touchPoint;
		DrawNode* drawNode = DrawNode::create();
		auto s = Director::getInstance()->getWinSize();
		Color4F color(touchColor.r / 255.0f, touchColor.g / 255.0f, touchColor.b / 255.0f, 1.0f);
		drawNode->drawLine(Vec2(0, touchPoint.y), Vec2(s.width, touchPoint.y), color);
		drawNode->drawLine(Vec2(touchPoint.x, 0), Vec2(touchPoint.x, s.height), color);
		drawNode->drawDot(touchPoint, 3, color);
		addChild(drawNode);
	}
开发者ID:HScarb,项目名称:tapthezergling,代码行数:11,代码来源:DoubleTapScene.cpp

示例13: onTouchMoved

void TestTouch::onTouchMoved(Touch* touch, Event* event)
{
	Point *locationInNode = &touch->getLocation();
	if (lastPoint != NULL)
	{
		DrawNode *draw = DrawNode::create();
		this->addChild(draw);	
		draw->drawSegment(Vec2(m_iLastPointX, m_iLastPointY), *locationInNode, 5, Color4F(0.5, 0.5, 0.5, 0.5));
	}
	CCLOG("TestTouch::onTouchMoved %p: %lf, %lf -->  %lf, %lf", lastPoint, m_iLastPointX, m_iLastPointY, locationInNode->x, locationInNode->y);
	m_iLastPointX = locationInNode->x;
	m_iLastPointY = locationInNode->y;
}
开发者ID:Alencai,项目名称:cocostest,代码行数:13,代码来源:TestTouch.cpp

示例14: removeAllChildren

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;
}
开发者ID:WarlockD,项目名称:Cocos2dx-Undertale-Engine,代码行数:50,代码来源:obj_dialoguer.cpp

示例15: DrawNode

DrawNode* DrawNode::create()
{
    DrawNode* pRet = new DrawNode();
    if (pRet && pRet->init())
    {
        pRet->autorelease();
    }
    else
    {
        CC_SAFE_DELETE(pRet);
    }
    
    return pRet;
}
开发者ID:bassarisse,项目名称:LostInCaves,代码行数:14,代码来源:CCDrawNode.cpp


注:本文中的DrawNode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。