コード例 #1
0
KDvoid GestureShapeLayer::draw ( KDvoid )
{	
	// Set line width.
	ccLineWidth ( 4.0f );
	
	// Set point size
	ccPointSize ( 16 );
	
	// Set color to blue
	ccDrawColor4B ( 255, 0, 0, 255 );

	// We either draw a circle or a series of lines
	if ( m_bDrawCircle )
	{
		// Draw a circle using circleRect information
		ccDrawCircle ( m_tCircleRect.origin, m_tCircleRect.size.cx, 0.0f, 100, KD_FALSE );
	}
	else if ( m_bDrawLines )
	{
		// Draw all lines
		for ( KDuint i = 0; i < m_pLines->count ( ); i++ )
		{
			GestureLine*	pLine = (GestureLine*) m_pLines->objectAtIndex ( i );
			ccDrawLine ( pLine->getPoint1 ( ), pLine->getPoint2 ( ) );
		}
	}
		
	// Restore original values
	ccLineWidth ( 1 );	
	ccDrawColor4B ( 255, 255, 255, 255 );
	ccPointSize ( 1 );		
}
コード例 #2
0
/// Draw layer 
KDvoid Ch7_SideScrollingPathfinding::drawLayer ( KDvoid )
{
	// Draw waypoints
	ccDrawColor4B ( 255, 255, 0, 128 );	

	b2Vec2		tPosition = m_pActor->getBody ( )->GetPosition ( );
	CCPoint		tActorPosition = ccp ( tPosition.x * PTM_RATIO, tPosition.y * PTM_RATIO );
		
	CCArray*	pWaypoints = m_pActor->getWaypoints ( );

	if ( pWaypoints->count ( ) == 1 )
	{
		GameWaypoint*	pWaypoint = (GameWaypoint*) pWaypoints->objectAtIndex ( 0 );
		ccDrawLine ( tActorPosition, pWaypoint->getPosition ( ) );
	}
	else if ( pWaypoints->count ( ) > 1 )
	{
		for ( KDuint i = 0; i < pWaypoints->count ( ) - 1; i++ )
		{			
			GameWaypoint*	pWaypoint	  = (GameWaypoint*) pWaypoints->objectAtIndex ( i );
			GameWaypoint*	pWaypointNext = (GameWaypoint*) pWaypoints->objectAtIndex ( i + 1 );
			
			if ( i == 0 )
			{
				// From actor to first waypoint
				ccDrawLine ( tActorPosition, pWaypoint->getPosition ( ) );
				ccDrawLine ( pWaypoint->getPosition ( ), pWaypointNext->getPosition ( ) );
			}
			else
			{
				// From this waypoint to next one
				ccDrawLine ( pWaypoint->getPosition ( ), pWaypointNext->getPosition ( ) );
			}	
		}
	}

	// Draw AStarNodes
	for ( KDuint i = 0; i < m_pNodes->count ( ); i++ )
	{
		// Draw node
		SSAStarNode*	pNode = (SSAStarNode*) m_pNodes->objectAtIndex ( i );	

		ccDrawColor4B ( 255, 255, 255, 128 );	
		ccDrawPoint ( pNode->getPosition ( ) );
		
		// Draw neighbor lines (there is going to be a lot of them)
		for ( KDuint j = 0; j < pNode->getNeighbors ( )->count ( ); j++ )
		{
			SSNeighborNode*		pNeighbor = (SSNeighborNode*) pNode->getNeighbors ( )->objectAtIndex ( j );
			
			ccDrawColor4B ( 128, 128, 128, 64 );
			ccDrawLine ( pNode->getPosition ( ), pNeighbor->getNode ( )->getPosition ( ) );
		}
		
	}	
}
コード例 #3
0
void DebugDraw::draw(Renderer *renderer, const Mat4& transform, uint32_t flags)
{
  int c = m_lines->size();
  for (int i = 0; i < c; i++)
  {
    DebugLine line = m_lines->at(i);
    ccDrawColor4B(line.r, line.g, line.b, 255);
    ccDrawLine(line.pt1, line.pt2);
  }

  c = m_points->size();
  for (int i = 0; i < c; i++)
  {
    DebugPoint pt = m_points->at(i);
    ccDrawColor4B(pt.r, pt.g, pt.b, 255);
    ccDrawPoint(pt.pt);
  }

  c = m_circles->size();
  for (int i = 0; i < c; i++)
  {
    DebugCircle ci = m_circles->at(i);
    ccDrawColor4B(ci.r, ci.g, ci.b, 255);
    ccDrawCircle(ci.pt, ci.radius, 0, 100, false, 1, 1);
  }
  c = m_rects->size();
  for (int i = 0; i < c; i++)
  {
    DebugRect ci = m_rects->at(i);
    ccDrawSolidRect(ci.pt1, ci.pt2, ci.color);
  }

  /*
  // size chart
  int totalLines = (m_visibleRectRightTop.x - m_visibleRectLeftBottom.x ) / 10;
  int colorIndex = 0;
  for (int i = m_visibleRectLeftBottom.x; i < m_visibleRectRightTop.x; i+= 10)
  {
  switch (colorIndex)
  {
  case 0: ccDrawColor4B(255, 255, 255, 255); break;
  case 1: ccDrawColor4B(255, 0, 0, 255); break;
  case 2: ccDrawColor4B(0, 255, 0, 255); break;
  case 3: ccDrawColor4B(0, 0, 255, 255); break;
  }
  colorIndex += (colorIndex == 3) ? -3 : 1;

  ccDrawLine(ccp (i, 0), ccp (i, i/m_visibleRectRightTop.x * m_visibleRectRightTop.y));
  }
  */
}
コード例 #4
0
void Gleed2DLayer::draw()
{
	SpriteBatchNode::draw();

	ccDrawInit();
	int numItem=_layerInfo->Items->count();
	for(int i=0;i<numItem;i++)
	{
		Gleed2DItem * item=(Gleed2DItem *)_layerInfo->Items->getObjectAtIndex(i);
		switch (item->_itemType)
		{
		case GLEED2D_ITEM_CIRCLE:
			{
				Gleed2DCircleItem * circleItem=(Gleed2DCircleItem *)item;
				ccDrawColor4B(circleItem->FillColor.r,circleItem->FillColor.g,circleItem->FillColor.b,circleItem->FillColor.a);
				ccDrawSolidCircle(Point(circleItem->Position.x,-(circleItem->Position.y))
							      ,circleItem->Radius
								  ,0
								  ,25
					);
			}break;
		case GLEED2D_ITEM_RECTANGLE:
			{
				Gleed2DRectangleItem * rectItem=(Gleed2DRectangleItem *)item;
				ccDrawColor4B(rectItem->FillColor.r,rectItem->FillColor.g,rectItem->FillColor.b,rectItem->FillColor.a);
				ccDrawSolidRect(Point(rectItem->Position.x,-(rectItem->Position.y))
								,Point(rectItem->Position.x+rectItem->Width,-(rectItem->Position.y)-rectItem->Height)
								,Color4F(rectItem->FillColor));
			}break;
		case GLEED2D_ITEM_PATH:
			{
				Gleed2DPathItem * pathItem=(Gleed2DPathItem *)item;
				int numPoint=pathItem->WorldPoints.size()-1;
				ccDrawColor4B(pathItem->LineColor.r,pathItem->LineColor.g,pathItem->LineColor.b,pathItem->LineColor.a);
			    float old_width;
				glGetFloatv(GL_LINE_WIDTH,&old_width);
				glLineWidth(pathItem->LineWidth);
				for(int i=0;i<numPoint;i++)
				{
					ccDrawLine(Point(pathItem->WorldPoints[i].x,-(pathItem->WorldPoints[i].y))
						      ,Point(pathItem->WorldPoints[i+1].x,-(pathItem->WorldPoints[i+1].y)));
				}
				glLineWidth(old_width);
			}break;
		default:
			break;
		}
		
	}
	ccDrawFree();
}
コード例 #5
0
void CCSkeleton::draw () {
	CC_NODE_DRAW_SETUP();

	ccGLBlendFunc(blendFunc.src, blendFunc.dst);
	ccColor3B color = getColor();
	skeleton->r = color.r / (float)255;
	skeleton->g = color.g / (float)255;
	skeleton->b = color.b / (float)255;
	skeleton->a = getOpacity() / (float)255;

	quadCount = 0;
	for (int i = 0, n = skeleton->slotCount; i < n; i++)
		if (skeleton->slots[i]->attachment) Attachment_draw(skeleton->slots[i]->attachment, skeleton->slots[i]);
	if (atlas) atlas->drawNumberOfQuads(quadCount);

	if (debugSlots) {
		// Slots.
		ccDrawColor4B(0, 0, 255, 255);
		glLineWidth(1);
		CCPoint points[4];
		for (int i = 0, n = skeleton->slotCount; i < n; i++) {
			if (!skeleton->slots[i]->attachment) continue;
			ccV3F_C4B_T2F_Quad* quad = &((Cocos2dxRegionAttachment*)skeleton->slots[i]->attachment)->quad;
			points[0] = ccp(quad->bl.vertices.x, quad->bl.vertices.y);
			points[1] = ccp(quad->br.vertices.x, quad->br.vertices.y);
			points[2] = ccp(quad->tr.vertices.x, quad->tr.vertices.y);
			points[3] = ccp(quad->tl.vertices.x, quad->tl.vertices.y);
			ccDrawPoly(points, 4, true);
		}
	}
	if (debugBones) {
		// Bone lengths.
		glLineWidth(2);
		ccDrawColor4B(255, 0, 0, 255);
		for (int i = 0, n = skeleton->boneCount; i < n; i++) {
			Bone *bone = skeleton->bones[i];
			float x = bone->data->length * bone->m00 + bone->worldX;
			float y = bone->data->length * bone->m10 + bone->worldY;
			ccDrawLine(ccp(bone->worldX, bone->worldY), ccp(x, y));
		}
		// Bone origins.
		ccPointSize(4);
		ccDrawColor4B(0, 0, 255, 255); // Root bone is blue.
		for (int i = 0, n = skeleton->boneCount; i < n; i++) {
			Bone *bone = skeleton->bones[i];
			ccDrawPoint(ccp(bone->worldX, bone->worldY));
			if (i == 0) ccDrawColor4B(0, 255, 0, 255);
		}
	}
}
コード例 #6
0
ファイル: RippleNode.cpp プロジェクト: agiantwhale/segments
void RippleNode::draw()
{
    CCNodeRGBA::draw();
    
    ccGLBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    
    ccDrawInit();
    
    ccDrawColor4B(getColor().r, getColor().g, getColor().b, getOpacity());
    
    glLineWidth(3.f * SCREEN_SCALE());
    ccPointSize(3.f * SCREEN_SCALE() * 0.5f);
    
    Rig rig;
    rig.reserve(RIG_VERTEXES());
    for(int i = 0; i < RIG_VERTEXES(); i++)
    {
        CCPoint vertex = ccpRotateByAngle(CCPointMake(0, 200.f * SCREEN_SCALE()), CCPointZero, M_PI * 2 * i / RIG_VERTEXES() + getRotation());
        rig.push_back(vertex);
    }
    
    ccDrawPoly(&rig[0], rig.size(), true);
    
    ccDrawPoint(CCPointZero);
    
    ccDrawFree();
    
    ccGLBlendFunc(CC_BLEND_SRC, CC_BLEND_DST);
    
    CC_INCREMENT_GL_DRAWS(1);
}
コード例 #7
0
void CCLineNode::draw()
{
	const ccColor3B& tColor(getColor());
	ccDrawColor4B(tColor.r, tColor.g, tColor.b, getOpacity());
	CCPoint tOrigin(isIgnoreAnchorPointForPosition() ? CCPointZero : getAnchorPointInPoints());
	ccDrawLine(tOrigin, ccpShift(tOrigin, getContentSize()));
}
コード例 #8
0
ファイル: CardBase.cpp プロジェクト: pope88/ChessCli
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;
}
コード例 #9
0
ファイル: SP_Block.cpp プロジェクト: faransae/Classes
void SP_Block::draw()
{
	CCSprite::draw();

	ccDrawColor4B(255, 255, 255, 255);
	ccDrawRect(ccp(0, 0), ccp(m_rcBB.size.width, m_rcBB.size.height));
}
コード例 #10
0
ファイル: Planet.cpp プロジェクト: wandermyz/CATLIEN
void Planet::drawSelection()
{
    ccDrawColor4B(255, 255, 255, 255);
    glLineWidth(3);
    
    ccDrawCircle(getPosition(), _radius, CC_DEGREES_TO_RADIANS(360), 50, false);
}
コード例 #11
0
void MultiFishAITestScene::debugDraw()
{
	ccDrawColor4B(255,0,0,255);
	CCRect drawRect = CCRectMake(20.f,20.0f,760.0f,440.0f);
	CCPoint dstPt = drawRect.origin+ccp(drawRect.size.width,drawRect.size.height);
	ccDrawRect(drawRect.origin,dstPt);
}
コード例 #12
0
ファイル: LineNode.cpp プロジェクト: gujianhesong/GujianDream
	virtual void draw()
	{
		ccDrawColor4B(m_TouchColor.r, m_TouchColor.g, m_TouchColor.b, 255);
		glLineWidth(3);
		ccDrawLine( ccp(0, 5), ccp(getContentSize().width, 5) );//2个坐标为画线的字父节点中的起点坐标和终点坐标
		glLineWidth(1);
	}
コード例 #13
0
ファイル: TTT.cpp プロジェクト: hugosouza/TTT-Test1
void TicTacToe::draw() {
    CHECK_GL_ERROR_DEBUG();
    glLineWidth(lineWidth);
    ccDrawColor4B(0,0,0,255);

    ccDrawLine(
        ccp(center.x-halfMark-lineWidth, center.y-halfMark-markSize-lineWidth),
        ccp(center.x-halfMark-lineWidth, center.y+halfMark+markSize+lineWidth)
     );
    ccDrawLine(
        ccp(center.x+halfMark, center.y-halfMark-markSize-lineWidth),
        ccp(center.x+halfMark, center.y+halfMark+markSize+lineWidth)
     );
    ccDrawLine(
        ccp(center.x-halfMark-markSize, center.y-halfMark-lineWidth),
        ccp(center.x+halfMark+markSize, center.y-halfMark-lineWidth)
     );
    ccDrawLine(
        ccp(center.x-halfMark-markSize, center.y+halfMark),
        ccp(center.x+halfMark+markSize, center.y+halfMark)
     );

    glLineWidth(1);
    ccDrawLine(ccp(center.x, VisibleRect::leftTop().y), ccp(center.x, VisibleRect::leftBottom().y));
    ccDrawLine(ccp(VisibleRect::leftTop().x, center.y), ccp(VisibleRect::rightTop().x, center.y));


    glLineWidth(1);
    ccDrawColor4B(0,255,0,255);

    //for (int i = 1; i <= 3; i++) {
    //    for (int j = 1; j <= 3; j++) {
    //        CCPoint a = m1->getCoordsForPosition(j,i);
    //        ccDrawLine(ccp(a.x, VisibleRect::leftTop().y), ccp(a.x, VisibleRect::leftBottom().y));
    //        ccDrawLine(ccp(VisibleRect::leftTop().x, a.y), ccp(VisibleRect::rightTop().x, a.y));
    //    }
    //}

    ccDrawLine(ccp(board00.x, VisibleRect::leftTop().y), ccp(board00.x, VisibleRect::leftBottom().y));
    ccDrawLine(ccp(VisibleRect::leftTop().x, board00.y), ccp(VisibleRect::rightTop().x, board00.y));

    if (foundWinner) {
        glLineWidth(10);
        ccDrawColor4B(255,0,0,255);
        ccDrawLine(winnerStart, winnerEnd);
    }
}
コード例 #14
0
void GGameLayerBase::draw()
{
	CCLayer::draw();
	//return;
	glLineWidth(1.5);
	CCRect dataRect;
	CCArray* arraychildren= _spriteLayer->getChildren();
	CCObject *obj=NULL;
	CCARRAY_FOREACH(arraychildren,obj)
	{
		ActionSprite *sprite=(ActionSprite*)obj;
		ccDrawColor4B(255, 0, 0, 255);
		dataRect=sprite->GetHitbox();
		ccDrawRect(dataRect.origin,ccp(dataRect.getMaxX(),dataRect.getMaxY()));
		ccDrawColor4B(0, 255, 0, 255);
		dataRect=sprite->GetAttackBox();
		ccDrawRect(dataRect.origin,ccp(dataRect.getMaxX(),dataRect.getMaxY()));
	}
コード例 #15
0
ファイル: MutiTouchTest.cpp プロジェクト: csdnnet/hiygame
 virtual void draw()
 {
     ccDrawColor4B(m_TouchColor.r, m_TouchColor.g, m_TouchColor.b, 255);
     glLineWidth(10);
     ccDrawLine( ccp(0, m_pTouchPoint.y), ccp(getContentSize().width, m_pTouchPoint.y) );
     ccDrawLine( ccp(m_pTouchPoint.x, 0), ccp(m_pTouchPoint.x, getContentSize().height) );
     glLineWidth(1);
     ccPointSize(30);
     ccDrawPoint(m_pTouchPoint);
 }
コード例 #16
0
		virtual KDvoid	draw ( KDvoid )
		{
			ccDrawColor4B ( m_tTouchColor.r, m_tTouchColor.g, m_tTouchColor.b, 200 );
			ccLineWidth ( 10 );
			ccDrawLine	( ccp ( 0, m_tTouchPoint.y ), ccp ( getContentSize ( ).cx, m_tTouchPoint.y ) );
			ccDrawLine	( ccp ( m_tTouchPoint.x, 0 ), ccp ( m_tTouchPoint.x, getContentSize ( ).cy ) );
			glLineWidth	( 1 );
			ccPointSize ( 30 );
			ccDrawPoint ( m_tTouchPoint );
		}
コード例 #17
0
ファイル: Elements.cpp プロジェクト: CludeX/SuperSector
void Barrier::draw()
{
    if(_isDisappear) return;

    float innerR,outerR;
    innerR = _parameter.innerR - GameScene::sharedInstance()->movedLength;
    outerR = _parameter.outerR - GameScene::sharedInstance()->movedLength;
    if(outerR <= 0.1)
    {
        //这句话可能造成屏幕闪烁
        //this->removeFromParent();

        //使用disappear()函数防止屏幕卡顿
        disappear();
        return;
    }
    if(innerR > 0.1)
    {

        CCSize size = CCDirector::sharedDirector()->getWinSize();
        ccDrawColor4B(146, 10, 36, 255);
        ccDrawAnnulus(ccp(0,0), innerR*size.width/2, outerR*size.width/2, CC_DEGREES_TO_RADIANS((_parameter.end-_parameter.start)*60), 20);
    }
    else if(outerR > 0.1)
    {
        innerR = 0.1;
        CCSize size = CCDirector::sharedDirector()->getWinSize();
        if(_parameter.outerR > _parameter.innerR)
        {
            ccDrawColor4B(146, 10, 36, 255);
            ccDrawAnnulus(ccp(0,0), innerR*size.width/2, outerR*size.width/2, CC_DEGREES_TO_RADIANS((_parameter.end-_parameter.start)*60), 20);
        }
    }
    //在这里做碰撞检测
    if(detactCollision())
    {
        GameScene::sharedInstance()->gameOver();
    }
    //glLineWidth(_outerRadius-_innerRadius);效果不好
    //ccDrawArc(ccp(0,0), _innerRadius, CC_DEGREES_TO_RADIANS((_end-_start)*60), 100, false);
    //ccDrawArc(ccp(0,0), _outerRadius, CC_DEGREES_TO_RADIANS((_end-_start)*60), 100, false);

}
コード例 #18
0
void GridLayer::DrawGridLines()
{
   // Draw the lines
   for(int idx = 0; idx < _pixelLines.size(); idx++)
   {
      ccDrawColor4B(20, 20, 128, 90);
      ccDrawCircle(_pixelLines[idx].start, 2, 0, 16, false, 1.0, 1.0);
      ccDrawCircle(_pixelLines[idx].end, 2, 0, 16, false, 1.0, 1.0);
      ccDrawLine(ccp(_pixelLines[idx].start.x,_pixelLines[idx].start.y),
                 ccp(_pixelLines[idx].end.x,_pixelLines[idx].end.y) );
   }   
}
コード例 #19
0
ファイル: BWDrawLayer.cpp プロジェクト: bingwan/PloySprite
void BWDrawLayer::draw()
{
    ccDrawColor4B(0,255,0,255);
    const int nNum = _vDrawPos.size();
    Point * PosArray = new Point[nNum];
    
    for(int i=0;i<nNum;++i)
    {
        PosArray[i] = _vDrawPos[i];
    }
    ccDrawSolidPoly(PosArray, nNum, Color4F(0,0,0,255) );
}
コード例 #20
0
ファイル: line.cpp プロジェクト: doublsky/assiduousme
void line::draw()
{
    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
    
    glLineWidth(2.0f);
    ccDrawColor4B(0, 0, 0, 255);
    ccDrawLine(ccp(origin.x+visibleSize.width/4-WIDTH/2, origin.y+visibleSize.height*2/3+HIGHT/2),
               ccp(origin.x+visibleSize.width*3/4+WIDTH/2, origin.y+visibleSize.height*2/3+HIGHT/2));
    ccDrawLine(ccp(origin.x+visibleSize.width/4-WIDTH/2, origin.y+visibleSize.height*2/3-HIGHT/2),
               ccp(origin.x+visibleSize.width*3/4+WIDTH/2, origin.y+visibleSize.height*2/3-HIGHT/2));
}
コード例 #21
0
void GameObject::draw()
{
	ccDrawColor4B(0, 255, 255, 255);

	CCRect r = this->adjustedBoundingBox();

	float xOffset = r.size.width * 0.1f;
	float yOffset = r.size.height * 0.3f;

	ccDrawRect( ccp(xOffset, yOffset), ccp(r.size.width, r.size.height) );

	CHECK_GL_ERROR_DEBUG();
}
コード例 #22
0
void GestureScene::draw() {
	if(isOnTouch) {
		ccPointSize(15);  
		ccDrawColor4B(255, 255, 0, 64);  

		if(mPoints.size() > 0) {
			glLineWidth( 50.0f );
			ccDrawPoint(mPoints[0]);  
			for(int i=1; i<mPoints.size(); i++)
				ccDrawLine(mPoints[i-1], mPoints[i]);
		}
		
	}
}
コード例 #23
0
ファイル: MapEditLayer.cpp プロジェクト: caoguoping/warCraft
void MapEditLayer::draw()
{
    CCLayerColor::draw();
    ccDrawColor4B(0,255,255,255);
    CHECK_GL_ERROR_DEBUG();
    for (int i = 0; i<9; i++)
    {
        ccDrawLine(ccp(30 +i*32, 100), ccp(30 +i*32,100 + 6* 32));
    }
    for (int j = 0; j< 7; j++)
    {
        ccDrawLine(ccp(30, 100 + j*32), ccp(30 + 8*32,100 + j*32));
    }
}
コード例 #24
0
ファイル: GameCell.cpp プロジェクト: mjssw/myproj
void CGameTableViewCell::draw()
{
	CCTableViewCell::draw();
	// draw bounding box
 	CCPoint pos = getPosition();
	CCSize size = CCSizeMake(GAME_ICON_WIDTH, GAME_ICON_HEIGHT);
 	CCPoint vertices[4]={
 		ccp(pos.x+1, pos.y+1),
 		ccp(pos.x+size.width-1, pos.y+1),
 		ccp(pos.x+size.width-1, pos.y+size.height-1),
 		ccp(pos.x+1, pos.y+size.height-1),
 	};
 	ccDrawColor4B(0, 0, 255, 255);
 	ccDrawPoly(vertices, 4, true);
}
コード例 #25
0
KDvoid Ch7_GridPathfinding::drawLayer ( KDvoid )
{
	// If we have less than two nodes in our path we return
	if ( !m_pFoundPath || m_pFoundPath->count ( ) < 2 )
	{
		return;
	}

	ccDrawColor4B ( 0, 0, 255, 255 );	
	
	// Draw all edges of the path
	for ( KDuint i = 0; i < m_pFoundPath->count ( ) - 1; i++ )
	{
		CCPoint		tPoint1 = ( (CCPointValue*) m_pFoundPath->objectAtIndex ( i     ) )->getValue ( ); 
		CCPoint		tPoint2 = ( (CCPointValue*) m_pFoundPath->objectAtIndex ( i + 1 ) )->getValue ( ); 
		ccDrawLine ( tPoint1, tPoint2 );
	}
}
コード例 #26
0
void CCRectNode::draw()
{
	const ccColor3B& tColor(getColor());
	CCPoint tOrigin(isIgnoreAnchorPointForPosition() ? CCPointZero : getAnchorPointInPoints());
	CCPoint tDestination(ccpShift(tOrigin, getContentSize()));

	if (m_bFill)
    {
		ccColor4F tColor4F(ccc4FFromccc3B(tColor));
		tColor4F.a = getOpacity() / 255.0f;
    	ccDrawSolidRect(tOrigin, tDestination, tColor4F);
    }
    else
    {
    	ccDrawColor4B(tColor.r, tColor.g, tColor.b, getOpacity());
    	ccDrawRect(tOrigin, tDestination);
    }
}
コード例 #27
0
void 
CPrimitiveScene::draw()
{    
    CCCamera* pCamera = CCDirector::sharedDirector()->getRunningScene()->getCamera();
    pCamera->setEyeXYZ(0,0,10);
    pCamera->setCenterXYZ(-50.0f, -50.0f, 0);

    // open yellow poly
    ccDrawColor4B(255, 255, 0, 255);
    glLineWidth(10);
    ccVertex3F vertices[] = { vertex3(0,0,0), vertex3(50,50,0), vertex3(100,50,0), vertex3(100,100,0), vertex3(50,100,0.1) };
        
    s_pShader->use();
    s_pShader->setUniformForModelViewProjectionMatrix();
    s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1);

    ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position );


    int numberOfPoints = 5;
    // XXX: Mac OpenGL error. arrays can't go out of scope before draw is executed
    ccVertex3F* newPoli = new ccVertex3F[numberOfPoints];

    // iPhone and 32-bit machines optimization
    if( sizeof(CCPoint) == sizeof(ccVertex3F) )
    {
        glVertexAttribPointer(kCCVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, 0, vertices);
    }
    else
    {
        // Mac on 64-bit
        for( unsigned int i=0; i<numberOfPoints;i++)
        {
            newPoli[i] = vertex3( vertices[i].x, vertices[i].y, vertices[i].z );
        }
        glVertexAttribPointer(kCCVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, 0, newPoli);
    }    

    glDrawArrays(GL_TRIANGLE_FAN, 0, (GLsizei) numberOfPoints);

    CC_SAFE_DELETE_ARRAY(newPoli);
    CC_INCREMENT_GL_DRAWS(1);
}
コード例 #28
0
KDvoid Waypoint::draw ( KDvoid )
{
	// Uncomment to draw waypoint circles and lines between them. For debug purpose only.
	ccDrawColor4B ( 128, 128, 0, 64 );

	CCPoint		tLocalCenter = CCNode::convertToNodeSpace ( this->getPosition ( ) );
	
	ccDrawCircle ( tLocalCenter, 6, 360, 30, KD_FALSE );
	ccDrawCircle ( tLocalCenter, 2, 360, 30, KD_FALSE );    

	if ( m_pNextWaypoint )
	{
		CCPoint		tNextWpPos = CCNode::convertToNodeSpace ( m_pNextWaypoint->getPosition ( ) );

		ccDrawLine ( tLocalCenter, tNextWpPos );
	}

    CCNode::draw ( );
}
コード例 #29
0
ファイル: CCRichAtlas.cpp プロジェクト: JoeHu/cocos2dx-ext
void CCRichAtlas::draw()
{
	if ( m_dirty )
	{
		this->updateRichRenderData();
	}

	CCAtlasNode::draw();

#if CCRICH_DEBUG
	// atlas bounding box
	const CCSize& s = this->getContentSize();
	CCPoint vertices[4]={
		ccp(0,0),ccp(s.width,0),
		ccp(s.width,s.height),ccp(0,s.height),
	};
	ccDrawColor4B(0x00, 0xff, 0x00, 0xff);
	ccDrawPoly(vertices, 4, true);
#endif
}
コード例 #30
0
void DrawNode::draw()
{
	ccDrawColor4B(ccRED.r,ccRED.g,ccRED.b,255);
	glLineWidth(2);
	if(1 == m_inflectionpointCount)
	{	
		ccDrawLine(m_startPoint,m_endPoint);
	}
	else if (2 == m_inflectionpointCount)
	{
		ccDrawLine(m_startPoint,m_inflectionpoint1);
		ccDrawLine(m_inflectionpoint1,m_endPoint);
	}
	else if (3 == m_inflectionpointCount)
	{
		ccDrawLine(m_startPoint,m_inflectionpoint1);
		ccDrawLine(m_inflectionpoint1,m_inflectionpoint2);
		ccDrawLine(m_inflectionpoint2,m_endPoint);
	}
}