本文整理汇总了C++中DrawNode::drawSegment方法的典型用法代码示例。如果您正苦于以下问题:C++ DrawNode::drawSegment方法的具体用法?C++ DrawNode::drawSegment怎么用?C++ DrawNode::drawSegment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DrawNode
的用法示例。
在下文中一共展示了DrawNode::drawSegment方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: 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();
}
示例4: 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;
}
示例5: parseMap
void DebugMap::parseMap( cocos2d::TMXTiledMap* tmap ){
TMXObjectGroup* wall = tmap->getObjectGroup("linewall");
Size mapSize = tmap->getContentSize();
tilesLen = tmap->getMapSize();
tilesSize= tmap->getTileSize()/2;
CCLOG("parseMap %f %f", D::mapSize.width, D::mapSize.height );
for( int i=0; i<tilesLen.height+1; i++ ) this->drawLine( Vec2( 0, i*(tilesSize.height)), Vec2( mapSize.width, i*(tilesSize.height) ), Color4F::BLUE );
for( int j=0; j<tilesLen.width+1; j++ ) this->drawLine( Vec2( j*(tilesSize.width), 0 ), Vec2( j*(tilesSize.width), mapSize.height ), Color4F::BLUE );
// CCLOG(" Line... %f, %f", tmap->getMapSize().width, tmap->getMapSize().height ); // 갯수
// CCLOG(" Line... %f, %f", tmap->getTileSize().width, tmap->getTileSize().height ); // 크기
DrawNode* wallNode = DrawNode::create();
this->addChild( wallNode );
int lineCount = 0;
for( auto obj : wall->getObjects())
{
bool first = true;
Vec2 prevPoint;
auto xx = obj.asValueMap()["x"].asFloat();
auto yy = obj.asValueMap()["y"].asFloat();
// 벽 생성 및 위치
for( auto value : obj.asValueMap() )
{
if( value.first == "polylinePoints"){
wallSeg.push_back( *new std::vector<Vec2> );
auto vec = value.second.asValueVector();
CCLOG("catch Line %d", lineCount );
first = true;
for( auto &p : vec ){
Vec2 point = Vec2( ( p.asValueMap().at("x").asFloat()*.5 ) + xx, -( p.asValueMap().at("y").asFloat()*.5 ) + yy );
if( first == false ){
wallNode->drawSegment( prevPoint, point, 3.0f, Color4F::WHITE );
}
wallSeg[lineCount].push_back(point);
prevPoint = point;
first = false;
}//for
CCLOG( "(%d) line length is %lu", lineCount, wallSeg[lineCount].size());
lineCount += 1;
}//if
}//for
}
parentMap.reserve(100);
getFastDistance( 8,0, 6,8 );
}
示例6: lookAt
///all screen move functions should use this
void HelloWorld::lookAt(Vec2 pos)
{
Vec2 visible = Director::getInstance()->getVisibleSize();
this->setPosition(-1*(pos - visible/2));
protractor->setPosition(lookingAt());
notifier->setPosition(lookingAt());
//draw grid
Vec2 botleft = screenspaceToWorldspace(Vec2::ZERO);
Vec2 topright = screenspaceToWorldspace(visible);
Vec2 drawSpaceBotLeft = botleft - GRID_LABEL_SPACING;
Vec2 drawSpaceTopRight = topright + GRID_LABEL_SPACING;
DrawNode* gridSprite = (DrawNode*)getChildByName("gridSprite");
if (gridSprite)
{
gridSprite->clear();
std::vector<std::string> toRemove;
for (auto child : gridSprite->getChildren())
{
if (!onScreen(child->getPosition(), Vec2(GRID_LABEL_SPACING)))
toRemove.push_back(child->getName());
}
for (auto name : toRemove)
{
gridSprite->removeChildByName(name);
}
}
else
{
gridSprite = DrawNode::create();
gridSprite->setName("gridSprite");
addChild(gridSprite, 0);
}
//vertical lines
for (int i= drawSpaceBotLeft.x; i<drawSpaceTopRight.x; i++)
{
if(i % (int)GRID_SPACING.x)
continue;
gridSprite->drawSegment(Vec2(i, drawSpaceBotLeft.y), Vec2(i, drawSpaceBotLeft.y+visible.y+2*GRID_LABEL_SPACING.y),
GRID_LINE_THICKNESS, Color4F(1,1,1,0.1));
if(!(i % (int)GRID_LABEL_SPACING.x))
{
std::string txt = std::to_string(i);
auto label = gridSprite->getChildByName("v" + txt);
if (!label)
{
label = Label::createWithTTF(txt, "fonts/arial.ttf", GRID_LABEL_SIZE);
label->setName("v" + txt);
gridSprite->addChild(label);
}
label->setPosition(Vec2(i, topright.y - GRID_LABEL_SIZE * 2));
}
}
//horizontal lines
for (int i= drawSpaceBotLeft.y; i<drawSpaceTopRight.y; i++)
{
if(i % (int)GRID_SPACING.y)
continue;
gridSprite->drawSegment(Vec2(drawSpaceBotLeft.x, i), Vec2(drawSpaceBotLeft.x+visible.x + 2 * GRID_LABEL_SPACING.x, i),
GRID_LINE_THICKNESS, Color4F(1,1,1,0.1));
if(!(i % (int)GRID_LABEL_SPACING.y))
{
std::string txt = std::to_string(i);
auto label = gridSprite->getChildByName("h" + txt);
if (!label)
{
label = Label::createWithTTF(txt, "fonts/arial.ttf", GRID_LABEL_SIZE);
label->setName("h" + txt);
gridSprite->addChild(label);
}
label->setPosition(Vec2(botleft.x + GRID_LABEL_SIZE * 2, i));
}
}
repaintCursor();
Commorose* c = (Commorose*)commorose;
c->setPosition(screenspaceToWorldspace(c->getPositionOnScreen()));
}