void HelloWorld::draw()
{
	// return;

	ccDrawColor4F(1.0f, 0.0f, 0.0f, 1.0f);
	CCRect beetleBox = beetle->boundingBox();
	//cocos2d::ccDrawRect(ccp(beetleBox.getMinX(), beetleBox.getMinY()), ccp(beetleBox.getMaxX(), beetleBox.getMaxY()));

	CCPoint beetleVertices[BEETLE_POLY_NUM];
	for(int i=0; i<BEETLE_POLY_NUM; i++){
		beetleVertices[i] = beetle->convertToWorldSpace(beetlePoly[i]);
	}
	cocos2d::ccDrawPoly(beetleVertices, BEETLE_POLY_NUM, true);

	CCPoint cactusVertices[CACTUS_POLY_NUM];
	for(int j=0; j<cactusNum; j++){
		for(int i=0; i<CACTUS_POLY_NUM; i++){
			cactusVertices[i] = cactusDown[j]->convertToWorldSpace(cactusDownPoly[i]);
		}
		cocos2d::ccDrawPoly(cactusVertices, CACTUS_POLY_NUM, true);

		for(int i=0; i<CACTUS_POLY_NUM; i++){
			cactusVertices[i] = cactusUp[j]->convertToWorldSpace(cactusUpPoly[i]);
		}
		cocos2d::ccDrawPoly(cactusVertices, CACTUS_POLY_NUM, true);
	}

	ccDrawColor4F(0.0f, 0.0f, 0.0f, 1.0f);
}
Esempio n. 2
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));
}
Esempio n. 3
0
void SlingSprite::draw()
{
    CCSprite::draw();
    ccDrawColor4F(1,1,1,1);
    ccDrawCircle(CCPoint(0,0),_radius, 0,_radius*2.0 , false);
    ccDrawCircle(CCPoint(0,0),1,0,_radius*2.0,false);
}
Esempio n. 4
0
void Sprite::draw()
{
    ccDrawColor4F(1, 1, 1, 1);
    if(_isTouch)
    {
        if(isClockwise())
        {
            _directAngle -= 7;
        }
        else
        {
            _directAngle += 7;
        }
    }
    float cx,cy,tx,ty,cl;
    cx = _radius*cos(CC_DEGREES_TO_RADIANS(_directAngle));
    cy = _radius*sin(CC_DEGREES_TO_RADIANS(_directAngle));
    cl = sqrtf(cx*cx+cy*cy);

    tx = cy/cl;
    ty = -cx/cl;

    CCPoint points[] = { CCPoint(cx+_baseLength/2*tx,cy+_baseLength/2*ty), CCPoint(cx-ty*_height,cy+tx*_height), CCPoint(cx-_baseLength/2*tx,cy-_baseLength/2*ty) };
    ccDrawPoly(points, sizeof(points)/sizeof(points[0]), true);
}
Esempio n. 5
0
void Sky::draw(Renderer *renderer, const Mat4& transform, uint32_t flags) {
    
    cocos2d::Size s = Director::getInstance()->getWinSize();
    
    DoodleTruck *doodleTruck = DoodleTruck::sharedDoodleTruck();
    CC_NODE_DRAW_SETUP();
    
    Vec2 _skyVertices[4];
    Vec2 _skyTexCoords[4];
    
    _skyVertices[0] = Vec2(0, 0);
    _skyTexCoords[0] = Vec2(1.0, 1.0f);
    _skyVertices[1] = Vec2(s.width, 0);
    _skyTexCoords[1] = Vec2(1.0f, 1.0f);
    
    _skyVertices[2] = Vec2(0, s.height);
    _skyTexCoords[2] = Vec2(31.0f, 63.0f);
    _skyVertices[3] = Vec2(s.width, s.height);
    _skyTexCoords[3] = Vec2(31.0f, 63.0f);
    
    
    Texture2D * tex = Director::getInstance()->getTextureCache()->textureForKey("sky-bg-rainbow.png");
    GL::bindTexture2D(tex->getName());
    GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION | GL::VERTEX_ATTRIB_FLAG_TEX_COORD);
    
    ccDrawColor4F(1.0f, 1.0f, 1.0f, 1.0f);
    glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, _skyVertices);
    glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, 0, _skyTexCoords);
    
    glDrawArrays(GL_TRIANGLE_STRIP, 0, (GLsizei)4);
    
   // ccDrawColor4F(1.0, 1.0, 1.0, 1.0);*/
}
Esempio n. 6
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 ));

}
Esempio n. 7
0
void drawTimeLine(Track * track, CCSize * size)
{
	ccColor4F baseColor=ccc4f(0.117f,0.0f,0.038f,0.6f/*9*/);
	ccDrawSolidRect(CCPoint(0,track->getContentSize().height),CCPoint(size->width,track->getContentSize().height+size->height),baseColor);
	float recThickness=4.0f;
	glLineWidth(recThickness);
	ccDrawColor4F(baseColor.r,baseColor.g,baseColor.b,0.9);
	ccDrawRect(ccp(0-recThickness,track->getContentSize().height-recThickness/2),ccp(size->width+recThickness/2 , track->getContentSize().height+size->height+recThickness/2));
}
Esempio n. 8
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);
	}
}
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) );
}
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);
}
Esempio n. 11
0
void SectorLayer::draw()
{
    float r = 0.1;
    CCSize size = CCDirector::sharedDirector()->getWinSize();
    ccDrawColor4F(1, 1, 1, 1);
    glLineWidth(2);
    ccDrawCircle(ccp(0,0), r*size.width/2, 360, 50, false);

    float l,w,h;
    w = size.width;
    h = size.height;
    l = sqrt(w*w + h*h);
    ccDrawColor4F(1.0,1.0,1.0,1.0);
    for(int i = 0; i < 6; i++)
    {
        ccDrawLine(ccp(r*size.width/2*cos(i*M_PI/3),r*size.width/2*sin(i*M_PI/3)), ccp(l*cos(i*M_PI/3),l*sin(i*M_PI/3)));
    }
    glLineWidth(1);
}
Esempio n. 12
0
void drawTPlayer(Track * track,CCPoint * timelineTrackRatio,CCSize * timeLineSize,float * addtionalDistance)
{
	float trackHeight=track->getHeight();
	float radius=timeLineSize->height/5;
	ccDrawColor4F(0.75f,0.0f,0.0f,0.8f);
	float newX=(track->_player->getPositionX() + *addtionalDistance)* timelineTrackRatio->x;
	float newY=timeLineSize->height/2 + trackHeight;
	
	ccDrawSolidCircle(ccp(newX,newY),radius,CC_DEGREES_TO_RADIANS(90),50,false);
}
Esempio n. 13
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;
    
    
}
Esempio n. 14
0
void Arrow::draw()
{
    CCSprite::draw();
    
#ifdef SHOW_BOUNDING_BOX
    CCPoint position(m_obAnchorPointInPoints.x + BOUNDING_BOX_LEFT, m_obAnchorPointInPoints.y + BOUNDING_BOX_BOTTOM);
    CCSize size(BOUNDING_BOX_RIGHT - BOUNDING_BOX_LEFT, BOUNDING_BOX_TOP - BOUNDING_BOX_BOTTOM);
    
    ccDrawColor4F(1.0f, 0.0f, 0.0f, 1.0f);
    ccDrawRect(position, size);
#endif
}
Esempio n. 15
0
void CCShapeNode::afterDraw(void)
{
    glLineWidth(1);    
    ccDrawColor4F(1, 1, 1, 1);
#ifdef GL_LINE_STIPPLE
    if (m_lineStippleEnabled)
    {
        glDisable(GL_LINE_STIPPLE);
        glLineStipple(1, 0xFFFF);
    }
#endif
}
Esempio n. 16
0
void CCShapeNode::beforeDraw(void)
{
    glLineWidth(m_lineWidth);
    ccDrawColor4F(m_color.r, m_color.g, m_color.b, m_color.a);
#ifdef GL_LINE_STIPPLE
    if (m_lineStippleEnabled)
    {
        glEnable(GL_LINE_STIPPLE);
        glLineStipple(1, m_lineStipple);
    }
#endif
}
Esempio n. 17
0
void Timeline::render(Track* track)
{
	CCSize * timeLineSize=new CCSize(CCDirector::sharedDirector()->getVisibleSize().width,CCDirector::sharedDirector()->getVisibleSize().height/20);
	CCPoint *timelineTrackRatio=new CCPoint(getTimelineTrackRatio(track,timeLineSize));
	float * addtionalDistance=new float(getDistanceFrom(track));
	drawTimeLine(track,timeLineSize);
	drawTBars(track,timelineTrackRatio,timeLineSize,addtionalDistance);
	drawTItems(track,timelineTrackRatio,timeLineSize,addtionalDistance);
	drawTPlayer(track,timelineTrackRatio,timeLineSize,addtionalDistance);
	ccDrawColor4F(0xFF,0xFF,0xFF,0xFF);
	glLineWidth(1.0f);
}
Esempio n. 18
0
void TerrainTest::drawHill()
{
    CC_NODE_DRAW_SETUP();
    GL::bindTexture2D(_stripes->getTexture()->getName());
    //    ccGLEnableVertexAttribs(kCCVertexAttribFlag_Position | kCCVertexAttribFlag_TexCoords);
    GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POSITION | GL::VERTEX_ATTRIB_FLAG_TEX_COORD);
    ccDrawColor4F(1.0f, 1.0f, 1.0f, 1.0f);
    glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, _hillVertices);
    glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, 0, _hillTexCoords);
    
    glDrawArrays(GL_TRIANGLE_STRIP, 0, (GLsizei)_nHillVertices);
    
}
Esempio n. 19
0
void RectangleNode::draw()
{
    CC_NODE_DRAW_SETUP();
    
    if (m_bSolid)
    {
        ccDrawSolidRect(CCPointZero, m_obContentSize, m_sColor);
    }
    else
    {
        ccDrawColor4F(m_sColor.r, m_sColor.g, m_sColor.b, m_sColor.a);
        
        ccDrawRect(CCPointZero, m_obContentSize);
    }
}
Esempio n. 20
0
void Forest::draw() {
	CCNode::draw();

	CC_NODE_DRAW_SETUP();

	ccGLBindTexture2D(_forestTexture->getName());
	ccGLEnableVertexAttribs(
			kCCVertexAttribFlag_Position | kCCVertexAttribFlag_TexCoords);

	ccDrawColor4F(1.0f, 1.0f, 1.0f, 1.0f);
	glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0,
			_forestVertices);
	glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0,
			_forestTexCoords);
	glDrawArrays(GL_TRIANGLES, 0, (GLsizei) _nForestVertices);
}
Esempio n. 21
0
void CCRectShape::drawProc(void)
{
    const CCPoint center = getDrawPosition();
    float w = m_size.width / 2;
    float h = m_size.height / 2;
    
    if (m_fill)
    {
        ccDrawSolidRect(ccp(center.x - w, center.y + h), ccp(center.x + w, center.y - h), m_color);
    }
    else
    {
        ccDrawColor4F(m_color.r, m_color.g, m_color.b, m_color.a);
        ccDrawRect(ccp(center.x - w, center.y + h), ccp(center.x + w, center.y - h));
    }
}
Esempio n. 22
0
void CCPolygonShape::drawProc(void)
{
    const CCPoint center = getDrawPosition();
    for (unsigned int i = 0; i < m_numberOfVertices; ++i)
    {
        m_verticesDraw[i].x = m_vertices[i].x + center.x;
        m_verticesDraw[i].y = m_vertices[i].y + center.y;
    }
    
    if (m_fill)
    {
        ccDrawSolidPoly(m_verticesDraw, m_numberOfVertices, m_color);
    }
    else
    {
        ccDrawColor4F(m_color.r, m_color.g, m_color.b, m_color.a);
        ccDrawPoly(m_verticesDraw, m_numberOfVertices, m_close);
    }
}
Esempio n. 23
0
void drawTItems(Track *track,CCPoint * timelineTrackRatio,CCSize * timeLineSize,float * addtionalDistance)
{
	
	float trackHeight=track->getHeight();
	float itemThickness=10.f;
	glLineWidth(itemThickness);
	float radius=timeLineSize->height/6;
	float newX,newY;
	for (int i=0;i < track->_items.size();i++)
	{
		if(track->_items[i]->getClassName()=="StarItem" &&  track->_items[i]->isVisible())
		{
			newX=(track->_items[i]->getPositionX()  + *addtionalDistance)* timelineTrackRatio->x;
			newY=timeLineSize->height/2 + trackHeight;
		//	ccDrawCircle(track->_items[i]->getPosition(),10,CC_DEGREES_TO_RADIANS(90),180,false,1.5f,1.5f);
			ccDrawColor4F(0.5f,0.1f,0.0f,0.1f);
			ccDrawCircle(ccp(newX,newY),radius,CC_DEGREES_TO_RADIANS(90),180,false,1.5f,1.5f);
		}
	}
}
Esempio n. 24
0
//virtual 
void SpellDiagramNode::draw()
{
	CCNode::draw();

	float ptSz = 5;

	ccDrawInit();
	ccPointSize(ptSz);
	glLineWidth(ptSz);
	//ccDrawColor4B(0, 0, 256, 256);
	ccDrawColor4F(0.0f, 0.0f, 1.0f, 1.0f);
    //ccDrawLine(ccp(0,0), ccp(100, 100));

	Json::Value& lines = m_spellDiagrams[m_type]["lines"];
	for( int i=0; i< lines.size(); i++)
	{
		std::string type = lines[i].get("type", "circle").asString();
		if( type.compare("circle") == 0 ) {
			ccDrawCircle(ccp(0,0), size/2, 0, 32, false);
		}else if( type.compare("bezier") == 0 ) {
			Json::Value& pts = lines[i]["points"];
			ccDrawCubicBezier(ccp(size*pts[0u].asDouble(), size*pts[1].asDouble()), 
							ccp(size*pts[2].asDouble(), size*pts[3].asDouble()),
							ccp(size*pts[4].asDouble(), size*pts[5].asDouble()),
							ccp(size*pts[6].asDouble(), size*pts[7].asDouble()), 32);
		}else if( type.compare("line") == 0 ) {
			Json::Value& pts = lines[i]["points"];
			ccDrawLine(ccp(size*pts[0u].asDouble(), size*pts[1].asDouble()), 
							ccp(size*pts[2].asDouble(), size*pts[3].asDouble()) );
		}
	}


/*

	if( m_type == SD_08_FORTRESS )  {
		//square shape
		ccDrawLine(ccp(-size/2 - ptSz/2, size/2), ccp(size/2 + ptSz/2, size/2)); //top
		ccDrawLine(ccp(-size/2 - ptSz/2, -size/2), ccp(size/2 + ptSz/2, -size/2)); //btm

		ccDrawLine(ccp(size/2, size/2), ccp(size/2 , -size/2)); //right
		ccDrawLine(ccp(-size/2, size/2), ccp(-size/2 , -size/2)); //left
	}

	if( m_type == SD_06_LESSER_TRIQUESTRA || m_type == SD_11_LEAF || 
		m_type == SD_13_GREATER_TRIQUETRA ) 
	{
		float topY = tA.y;
		float botY = tB.y;
		float midY = 0;

		CCPoint lcp1 = ccp(size*0.1666, -size*0.2167);
		CCPoint lcp2 = ccp(size*0.3335, size*0.1233);
		ccDrawCubicBezier(tC, lcp1, lcp2, tA, 32); //left

		CCPoint rcp1 = ccp(-size*0.1666, -size*0.2167);
		CCPoint rcp2 = ccp(-size*0.3335, size*0.1233);
		ccDrawCubicBezier(tB, rcp1, rcp2, tA, 32); //right

		CCPoint bcp1 = ccp(-size*0.25, size*0.286);
		CCPoint bcp2 = ccp( size*0.25, size*0.286);
		ccDrawCubicBezier(tC, bcp1, bcp2, tB, 32); //bottom
	}

	if( m_type == SD_07_COMPASS || m_type == SD_03_ADEPTS_CIRCLE ) {
		ccDrawLine(ccp(0, size/2), ccp(0, -size/2)); 
	}

	if( m_type == SD_05_SERPENTS_EYE ) {
		//shorter verticle line for eye
		ccDrawLine( seT, seB);
	}

	if( m_type == SD_11_LEAF ) {
		//offset verticle line for leaf
		ccDrawLine(leT, leB);
	}

	if( m_type == SD_09_DRAGONS_EYE ) {
		//shorter eye
		CCPoint t = ccp(0, size*0.38);
		CCPoint b = ccp(0, -size*0.38);
		CCPoint rcp1 = ccp(size/3,size/5);
		CCPoint rcp2 = ccp(size/3,-size/5);
		ccDrawCubicBezier(t, rcp1, rcp2, b, 32);
		CCPoint lcp1 = ccp(-size/3,size/5);
		CCPoint lcp2 = ccp(-size/3,-size/5);
		ccDrawCubicBezier(t, lcp1, lcp2, b, 32);
	}

	if( m_type == SD_10_SEEING_EYE ) {
		//shorter eye
		ccDrawCubicBezier(ccp(-size/2, 0), ccp(-size/3, size/4), ccp(size/3,size/4), ccp(size/2,0), 32);
		ccDrawCubicBezier(ccp(-size/2, 0), ccp(-size/3, -size/4), ccp(size/3,-size/4), ccp(size/2,0), 32);
	}

	if( m_type == SD_07_COMPASS  ) {
		//horizontal line
		ccDrawLine(ccp(-size/2, 0), ccp(size/2, 0));
	}
	*/
}