Пример #1
0
/* Draw all waypoint lines */
void Waypoints::drawLayer()
{
    glColorMask(255,255,0,32);
	//glColor4ub(255,255,0,32);
 
	CCPoint actorPosition = ccp(actor->body->GetPosition().x*PTM_RATIO, actor->body->GetPosition().y*PTM_RATIO);
   // CCLog("actor->waypoints->count() %d",actor->waypoints->count());
	if(actor->waypoints->count() == 1){
       
		GameWaypoint *gw = (GameWaypoint*)actor->waypoints->objectAtIndex(0);
		ccDrawLine(actorPosition, gw->position);
	}else if(actor->waypoints->count() > 1){
        for(int i=0; i<actor->waypoints->count()- 1; i++){
			GameWaypoint *gw = (GameWaypoint*)actor->waypoints->objectAtIndex(i);
			GameWaypoint *gwNext = (GameWaypoint*)actor->waypoints->objectAtIndex(i+1);
			
			if(i == 0){
				//From actor to first waypoint
				ccDrawLine(actorPosition, gw->position);
				ccDrawLine(gw->position, gwNext->position);
			}else{
				//From this waypoint to next one
				ccDrawLine(gw->position, gwNext->position);
			}
		}
	}
	 glColorMask(255,255,255,255);
	 
}
void ccDrawRect( CCPoint origin, CCPoint destination )
{
    ccDrawLine(CCPointMake(origin.x, origin.y), CCPointMake(destination.x, origin.y));
    ccDrawLine(CCPointMake(destination.x, origin.y), CCPointMake(destination.x, destination.y));
    ccDrawLine(CCPointMake(destination.x, destination.y), CCPointMake(origin.x, destination.y));
    ccDrawLine(CCPointMake(origin.x, destination.y), CCPointMake(origin.x, origin.y));
}
Пример #3
0
void My3DCursor::drawCursor()
{
	ccDrawPoly(drawBufferPoint+1, 5, true);
	ccDrawLine(drawBufferPoint[0], drawBufferPoint[1]);
	ccDrawLine(drawBufferPoint[0], drawBufferPoint[2]);
	ccDrawLine(drawBufferPoint[0], drawBufferPoint[3]);
	ccDrawLine(drawBufferPoint[0], drawBufferPoint[4]);
	ccDrawLine(drawBufferPoint[0], drawBufferPoint[5]);
}
/// 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 ( ) );
		}
		
	}	
}
		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 );
		}
Пример #6
0
void HudLayer::draw()
{
    CCLayer::draw();
    ccDrawColor4F(0,0,0,255);
    glLineWidth(5);
    ccDrawLine(CCPointMake(13,SCREEN.height-8),CCPointMake(13+10*Hero::sharedHero()->getMaxHP(),SCREEN.height-8));
    ccDrawColor4F(0,255,0,255);
    glLineWidth(5);
    ccDrawLine(CCPointMake(10,SCREEN.height-11),CCPointMake(10+10*Hero::sharedHero()->getHP(),SCREEN.height-11));
}
Пример #7
0
 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);
 }
Пример #8
0
    void NdCxListItem::draw(void)
    {
        updateColor();

        CCSize size = getContentSize();
        if (selected_)
        {
            glDisableClientState(GL_TEXTURE_COORD_ARRAY);
            glDisable(GL_TEXTURE_2D);
            glShadeModel(GL_SMOOTH);

            glVertexPointer(2, GL_FLOAT, 0, m_pSquareVertices);
            glColorPointer(4, GL_UNSIGNED_BYTE, 0, m_pSquareColors);

            bool newBlend = false;
            if( m_tBlendFunc.src != CC_BLEND_SRC || m_tBlendFunc.dst != CC_BLEND_DST ) {
                newBlend = true;
                glBlendFunc(m_tBlendFunc.src, m_tBlendFunc.dst);
            }
            else if( m_cOpacity != 255 ) {
                newBlend = true;
                glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
            }

            glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

            if( newBlend )
                glBlendFunc(CC_BLEND_SRC, CC_BLEND_DST);

            // restore default GL state
            glShadeModel(GL_FLAT);
            glEnableClientState(GL_TEXTURE_COORD_ARRAY);
            glEnable(GL_TEXTURE_2D);
        }
        else
        {
            CCLayerColor::draw();
        }
        
        glDisable(GL_LINE_SMOOTH);

        if (draw_top_line_)
        {
            glLineWidth(1.0f);
            glColor4ub(line_color_.r, line_color_.g, line_color_.b, 0xFF);
            ccDrawLine(CCPointMake(0, size.height-0.5f), CCPointMake(size.width, size.height-0.5f));
        }

        if (draw_bottom_line_)
        {
            glLineWidth(1.0f);
            glColor4ub(line_color_.r, line_color_.g, line_color_.b, 0xFF);
            ccDrawLine(CCPointMake(0, 0.5f), CCPointMake(size.width, 0.5f));
        }
    }
Пример #9
0
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));
}
Пример #10
0
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));
    }
}
Пример #11
0
	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);
	}
Пример #12
0
void LineContainer::draw()
{
    //draw energy bar
    ccDrawColor4F(0.0, 0.0, 0.0, 1.0);
    glLineWidth( _screenSize.width * 0.005 );
    ccDrawLine( ccp( _energyLineX ,  _screenSize.height * 0.3 ) ,
               
                ccp( _energyLineX ,  _screenSize.height * 0.9 ) ) ;
    if ( _energy > 0.2 )
        ccDrawColor4F(1.0, 0.5, 0.0, 1.0 ) ;
    else
        ccDrawColor4F(1.0, 0.0, 0.0, 1.0 ) ;
    ccDrawLine( ccp ( _energyLineX , _screenSize.height * 0.3 ) ,
               ccp ( _energyLineX , _screenSize.height * 0.3 + _energy * _energyHeight ));

}
Пример #13
0
void ContourSprite::draw()
{
    if (!m_bDrawContour)
    {
        return;
    }
    
    CCObject *_object = NULL;
    CCARRAY_FOREACH(m_pContourList, _object)
    {
        ContourData *_contourData = (ContourData*)_object;
        
        const CCArray *_vertexList = _contourData->getVertexList();
        
        int _length = _vertexList->data->num;
        CCPoint **x = (CCPoint**)_vertexList->data->arr;
        int _nextIndex = 0;
        
        for (int i=0; i<_length; i++)
        {
            _nextIndex = i+1;
            if (_nextIndex >= _length)
            {
                _nextIndex = 0;
            }
            
            ccDrawLine(*x[i], *x[_nextIndex]);
        }
    }
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 );		
}
Пример #15
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()));
}
Пример #16
0
void ForceLines::draw()
{
	CCLayer::draw();

	glLineWidth( 1.0f );
	glColor4f(1.0, 0.0, 0.0, 1.0);

	vector<vector<CCPoint *> *>::iterator it;
	for (it = this->lines.begin(); it != this->lines.end(); it++) {
		vector<CCPoint *> *line = *it;
		unsigned int i = 0;

		if (line->size() <= 1) {
			continue;
		}

		if (it+1 == this->lines.end()) {
			glColor4f(1.0, 1.0, 0.0, 1.0);
		}

		for (i = 0; i != line->size()-1; i++) {
			ccDrawLine( *((*line)[i]), *((*line)[i+1]) );
		}
	}
}
Пример #17
0
void TetrisGameLayer::draw(void){
//    CCPoint s = ccp(drawRect.origin.x,drawRect.origin.y);
//    CCPoint e = ccp(drawRect.size.width,drawRect.size.height);
//    ccDrawRect(s,e);
    //画背景格子//
    for (int i=0; i<_c; i++) {
        CCPoint s = ccp(i*_w,0);
        CCPoint e = ccp(i*_w,1136);
        ccDrawLine(s, e);
    }
    
    for (int j=0; j<_r; j++) {
        CCPoint s = ccp(0,j*_h);
        CCPoint e = ccp(640,j*_h);
        ccDrawLine(s, e);
    }
}
Пример #18
0
void GridView::drawGrid()
{
	//кЗМ├лж¤▀╗Ток
	glEnable(GL_LINE_STIPPLE);
	glLineStipple(1, 0xaaaa);

	float width_gap = m_frameSize.width / m_gap;
	float height_gap = m_frameSize.height / m_gap;
	//╗Ток╩Щ═ЭИы
	for (float pos_x = width_gap; pos_x <= m_frameSize.width ; pos_x += width_gap)
		ccDrawLine(ccp(pos_x, 0), ccp(pos_x, m_frameSize.height));
	//╗Ток║р═ЭИы
	for (float pos_y = height_gap; pos_y <= m_frameSize.height ; pos_y += height_gap)
		ccDrawLine(ccp(0,pos_y), ccp(m_frameSize.width,pos_y));

	glDisable(GL_LINE_STIPPLE);
}
Пример #19
0
void EnergyContainer::draw()
{
    CCNode::draw();
    
    float totalWidth = _winSize.width * 0.8f;
    
    ccDrawColor4F(0.0, 1.0, 1.0, 1.0);
    ccDrawLine( ccp(_energyX, _energyY), ccp(_energyX + totalWidth, _energyY) );
}
Пример #20
0
void HelloWorld::draw()
{
    glLineWidth( 1.0f );
    ccDrawColor4F(1.0f, 0.0f, 0.0f, 1.0f);
	for (int i = 0; i < pathArray->count(); i++) {
		PathObject *pO = (PathObject*) pathArray->objectAtIndex(i);
		ccDrawLine(*pO->startPosition, *pO->endPosition);
	}
}
Пример #21
0
void LineBlockMap::draw()
{
			
	glLineWidth( 10);
	for (std::vector<Line>::iterator iter = _lines.begin(); iter != _lines.end();++iter)
	{
		ccDrawLine(iter->src,iter->dest);
	}		//画线段,也可以使用点
	glLineWidth(1);
}
void DebugQuad(const ccV3F_C4B_T2F_Quad& quad)
{
    CCPoint points[] = {CCPointMake(quad.tl.vertices.x, quad.tl.vertices.y), CCPointMake(quad.tr.vertices.x, quad.tr.vertices.y),
        CCPointMake(quad.br.vertices.x, quad.br.vertices.y), CCPointMake(quad.bl.vertices.x, quad.bl.vertices.y),};

    ccDrawColor4F(1, 0, 0, 1);
    ccDrawLine(points[0], points[1]);
    
    ccDrawColor4F(0, 1, 0, 1);
    ccDrawLine(points[1], points[2]);
    
    ccDrawColor4F(0, 0, 1, 1);
    ccDrawLine(points[2], points[3]);

    ccDrawColor4F(0, 1, 1, 1);
    ccDrawLine(points[3], points[0]);

    ccDrawColor4F(1, 1, 1, 1);
}
void CtinyWingsTerrainSprite::drawWire(){
    vector<CCPoint>&pointList=m_pointMat[0];
    //draw segList
    {
        glLineWidth(2);
        ccPointSize(4);
        int nPoint=(int)pointList.size();
        int nSeg=nPoint-1;
        for(int i=0;i<nSeg;i++){
            CCPoint point=pointList[i];
            CCPoint pointn=pointList[i+1];
            ccDrawLine(point, pointn);
            ccDrawPoint(point);
            ccDrawPoint(pointn);
        }
    }
    
    //draw mesh
    {
        glLineWidth(2);
        int nRow=(int)m_pointMat.size();
        for(int i=0;i<nRow-1;i++){
            int nPoint=(int)m_pointMat[i].size();
            for(int j=0;j<nPoint-1;j++){
                const CCPoint&pLU=m_pointMat[i][j];
                const CCPoint&pLD=m_pointMat[i+1][j];
                const CCPoint&pRU=m_pointMat[i][j+1];
                const CCPoint&pRD=m_pointMat[i+1][j+1];
            
                ccDrawLine(pLU, pLD);
                ccDrawLine(pLD, pRD);
                ccDrawLine(pRD, pRU);
                ccDrawLine(pRU, pLU);
            }
        }
        
    }
    

    
    
}
Пример #24
0
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);
    }
}
Пример #25
0
void CCListViewCell::draw(void)
{
    CCLayerColor::draw();    
    CCSize size = this->getContentSize();
    CCListView *owner = this->getOwner();
    if (CCListViewCellSeparatorStyleSingleLine == m_nSeparatorStyle)
    {
        glLineWidth(1.0f);
        ccDrawColor4B(m_separatorLineColor.r, m_separatorLineColor.g, m_separatorLineColor.b, 255);

        if (CCListViewModeHorizontal == owner->getMode())
        {
            ccDrawLine(CCPointMake(size.width, 0), CCPointMake(size.width, size.height));
        }
        else if (CCListViewModeVertical == owner->getMode())
        {
            ccDrawLine(CCPointMake(0, 0), CCPointMake(size.width, 0));
        }
    }
}
Пример #26
0
bool LayerGame::init()
{
    CCSize sizeWin = CCDirector::sharedDirector()->getWinSize();
    if (!CCLayer::init()) {
        return false;
    }
    //背景
    CCLayerGradient* layer1 = CCLayerGradient::create(ccc4(160,210,210,255), ccc4(110,210,190,255), ccp(.0f, .0f));
    addChild(layer1, 0);
    
    GroundLayer* layerGround = GroundLayer::create();
    addChild(layerGround);
    
    _spRuner = SpriteRunner::create();
    
    _spRuner->setPosition(ccp(200,400));
    _spRuner->setRotation(45);
    addChild(_spRuner);
    
    this->setTouchEnabled(true);
    CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, 0, true);
    
    //this->m_pSpriteBatchNode=CCSpriteBatchNode::create("main.png", 100);

    this->m_pSpriteBatchNode = CCSpriteBatchNode::create("*****@*****.**", 100);
    addChild(m_pSpriteBatchNode);
    start();
    
    glLineWidth( 5.0f );
    ccDrawColor4F(255,0,0,40);
    ccDrawLine(ccp(0, 0), ccp(200, 400));
    /*
    
    CCLayerColor* layerBg = CCLayerColor::create(ccc4(0, 255, 255, 255), sizeWin.width, sizeWin.height);
    addChild(layerBg,0);
    CCSprite* spNormal = CCSprite::create();
    CCMenuItemSprite* btnStart = CCMenuItemSprite::create(spNormal,spNormal,this,menu_selector(LayerGame::callbackStart));
    btnStart->setPosition(ccp(sizeWin.width/2,sizeWin.height/2));
    
    CCMenuItemLabel* menuItem = CCMenuItemLabel::create(CCLabelTTF::create("播放视频", "黑体", 40), this, menu_selector(LayerGame::callbackStart));
    
    CCMenu* menu = CCMenu::create(menuItem,NULL);
    
    menu->setPosition(ccp(sizeWin.width/2, sizeWin.height/2));
    this->addChild(menu);
    */
    
    start();
    
    
    return true;
    
    
}
Пример #27
0
void GPSSprite::draw(Renderer* renderer, const kmMat4& transform, bool transformUpdated) {
    
    cocos2d::Size s = Director::getInstance()->getWinSize();
	
	int show_len = s.width * 2;
	int forward_len = s.width/2;
	double r_x = this->getContentSize().width/show_len;
	int begin_ix = -1;
	int end_ix = 0;
	for (int i = 0; i < roadManager->points(); i++) {
		cpVect pt = roadManager->point(i);
		if (pt.x > startPos + forward_len && begin_ix < 0) {
			begin_ix = i - 1;
		}
		if (pt.x > startPos + show_len + forward_len) {
			end_ix = i ;
			break;
		}
	}
	
	for (int i = begin_ix; i <= end_ix - 1; i++) {
        Vec2 pt1 = Vec2(roadManager->point(i).x, roadManager->point(i).y);
		Vec2 pt2 = Vec2(roadManager->point(i+1).x, roadManager->point(i+1).y);
		pt1 = Vec2(pt1.x - startPos - forward_len, pt1.y + s.height/4) * r_x;
		pt2 = Vec2(pt2.x - startPos - forward_len, pt2.y + s.height/4) * r_x;
		
		Vec2 pt3 = Vec2(pt1.x, pt1.y - 1);
		Vec2 pt4 = Vec2(pt2.x, pt2.y - 1);
		
		if (i == begin_ix)
			adjustPt(&pt1, &pt3, NULL);
		else if (i == end_ix - 1) 
			adjustPt(&pt2, &pt4, NULL);
		
		ccDrawLine(pt1, pt2);
		ccDrawLine(pt3, pt4);
	}
	
    Sprite::draw(renderer, transform, transformUpdated);

}
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) );
   }   
}
Пример #29
0
void Trooper::draw(){
	if (m_current_sprite==NULL){
		return;
	}
	return;
	CCRect box = CCRectMake(
			-(m_current_sprite->getTextureRect().size.width/2) * m_current_sprite->getScaleX(),
			-(m_current_sprite->getTextureRect().size.height/2) * m_current_sprite->getScaleY(),
			m_current_sprite->getTextureRect().size.width * m_current_sprite->getScaleX() ,
			m_current_sprite->getTextureRect().size.height * m_current_sprite->getScaleY()
	);
	const CCPoint p1 = CCPoint(box.origin.x, box.origin.y);
	const CCPoint p2 = CCPoint(box.origin.x+box.size.width, box.origin.y);
	const CCPoint p3 = CCPoint(box.origin.x+box.size.width, box.origin.y+box.size.height);
	const CCPoint p4 = CCPoint(box.origin.x, box.origin.y+box.size.height);
	ccDrawLine(p1, p2);
	ccDrawLine(p2, p3);
	ccDrawLine(p3, p4);
	ccDrawLine(p4, p1);
	CCNode::draw();
}
Пример #30
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();
}