CCParticleSystem* AchievementNotification::createPar(CCPoint pos,const char* file,float width,float height) { CCParticleSystem *m_emitter = new CCParticleSnow(); m_emitter->initWithTotalParticles(100); addChild(m_emitter, 10); m_emitter->setPosition(pos); m_emitter->setPosVar(ccp(width,height)); m_emitter->setLife(1.0f); m_emitter->setLifeVar(0.5f); m_emitter->setAutoRemoveOnFinish(true); m_emitter->setDuration(1.0f); m_emitter->setGravity(CCPointMake(0,-10)); m_emitter->setSpeed(130); m_emitter->setSpeedVar(30); m_emitter->setStartColor(ccc4f(0.5f,0.5f,0.5f,1.0f)); m_emitter->setStartColorVar(ccc4f(0.5f,0.5f,0.5f,0.1f)); m_emitter->setEndColor(ccc4f(0.1f,0.1f,0.1f,0.2f)); m_emitter->setEndColorVar(ccc4f(0.1f,0.1f,0.1f,0.2f)); m_emitter->setEndSpinVar(360); m_emitter->setEmissionRate(m_emitter->getTotalParticles()/m_emitter->getLife()); m_emitter->setTexture( CCTextureCache::sharedTextureCache()->addImage(file) ); m_emitter->setBlendAdditive(true); return m_emitter; }
bool Bug458Layer::init() { if(BugsTestBaseLayer::init()) { // ask director the the window size CCSize size = CCDirector::sharedDirector()->getWinSize(); QuestionContainerSprite* question = new QuestionContainerSprite(); QuestionContainerSprite* question2 = new QuestionContainerSprite(); question->init(); question2->init(); // [question setContentSize:CGSizeMake(50,50)]; // [question2 setContentSize:CGSizeMake(50,50)]; CCMenuItemSprite* sprite = CCMenuItemSprite::itemFromNormalSprite(question2, question, this, menu_selector(Bug458Layer::selectAnswer)); CCLayerColor* layer = CCLayerColor::layerWithColorWidthHeight(ccc4f(0,0,255,255), 100, 100); question->release(); question2->release(); CCLayerColor* layer2 = CCLayerColor::layerWithColorWidthHeight(ccc4f(255,0,0,255), 100, 100); CCMenuItemSprite* sprite2 = CCMenuItemSprite::itemFromNormalSprite(layer, layer2, this, menu_selector(Bug458Layer::selectAnswer)); CCMenu* menu = CCMenu::menuWithItems(sprite, sprite2, NULL); menu->alignItemsVerticallyWithPadding(100); menu->setPosition(ccp(size.width / 2, size.height / 2)); // add the label as a child to this Layer addChild(menu); return true; } return false; }
void GameEntityView::doLifedrain( ICastEntity* to ) { CCParticleFire* life = CCParticleFire::createWithTotalParticles(25); CCPoint point = m_healthBar->boundingBox().origin; life->setStartColor( ccc4f(0,1.0f,0,1.0f) ); life->setEndColor( ccc4f(0,1.0f,0,1.0f) ); life->setPosition(ccp(0,0)); //TODO: use physics interface to get position of 'to' entity and direct stream life->setGravity( CCPointMake( -30, 0 ) ); life->setStartSize(25); life->setPosVar( CCPointMake( 10,10 )); m_healthBar->addChild(life); CCSequence* seq = CCSequence::create( CCDelayTime::create(0.5f), CCCallFunc::create(life, callfunc_selector(CCParticleFire::stopSystem)), CCDelayTime::create(2.5f), CCRemoveSelf::create(true), NULL ); life->runAction(seq); }
//------------------------------------------------------------------ // // Effect5 // //------------------------------------------------------------------ void Issue631::onEnter() { EffectAdvanceTextLayer::onEnter(); CCActionInterval* effect = (CCActionInterval*)(CCSequence::actions( CCDelayTime::actionWithDuration(2.0f), CCShaky3D::actionWithRange(16, false, ccg(5, 5), 5.0f), NULL)); // cleanup CCNode* bg = getChildByTag(kTagBackground); removeChild(bg, true); // background CCLayerColor* layer = CCLayerColor::layerWithColor( ccc4f(255,0,0,255) ); addChild(layer, -10); CCSprite* sprite = CCSprite::spriteWithFile("Images/grossini.png"); sprite->setPosition( ccp(50,80) ); layer->addChild(sprite, 10); // foreground CCLayerColor* layer2 = CCLayerColor::layerWithColor(ccc4f( 0, 255,0,255 ) ); CCSprite* fog = CCSprite::spriteWithFile("Images/Fog.png"); ccBlendFunc bf = {CC_SRC_ALPHA, CC_ONE_MINUS_SRC_ALPHA}; fog->setBlendFunc(bf); layer2->addChild(fog, 1); addChild(layer2, 1); layer2->runAction( CCRepeatForever::actionWithAction(effect) ); }
//------------------------------------------------------------------------- void FKCW_RenderEx_EraserSprite::setDrawWidth(float var) { this->m_fDrawWidth = var; switch (m_uiDrawType) { case 0: //< 正方形模式 { m_pEraser->drawDot(CCPointZero, m_fDrawWidth, ccc4f(0,0,0,0)); } break; case 1: { // 绘制圆形区域 float fRadius = m_fDrawWidth; // 圆的半径 const int nCount = 100; // 用正100边型来模拟园 const float coef = 2.0f * (float)M_PI/nCount; // 计算每两个相邻顶点与中心的夹角 static CCPoint circle[nCount]; // 顶点数组 for(unsigned int i = 0;i <nCount; i++) { float rads = i*coef; // 弧度 circle[i].x = fRadius * cosf(rads); // 对应顶点的x circle[i].y = fRadius * sinf(rads); // 对应顶点的y } m_pEraser->drawPolygon(circle, nCount, ccc4f(0, 0, 0, 0), 0, ccc4f(0, 0, 0, 0));//绘制这个多边形! } break; case 2: { /// 需要自定义擦除图片 } break; default: break; } }
//-------------------------------------------------------- void CRenderTextureLayer::AddTopLight( CCPoint* vertices, ccColor4F* colors ) { int nVertices = 0; float borderHeight = RENDER_TEX_HEIGHT / 16; float borderAlpha = 0.7f; nVertices = 0; vertices[nVertices] = ccp(0, 0); colors[nVertices++] = ccc4f(1, 1, 1, borderAlpha); vertices[nVertices] = ccp(RENDER_TEX_WIDTH, 0); colors[nVertices++] = ccc4f(1, 1, 1, borderAlpha); vertices[nVertices] = ccp(0, borderHeight); colors[nVertices++] = ccc4f(0, 0, 0, 0); vertices[nVertices] = ccp(RENDER_TEX_WIDTH, borderHeight); colors[nVertices++] = ccc4f(0, 0, 0, 0); glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices); glVertexAttribPointer(kCCVertexAttrib_Color, 4, GL_FLOAT, GL_TRUE, 0, colors); glBlendFunc(CC_BLEND_SRC, CC_BLEND_DST); glDrawArrays(GL_TRIANGLE_STRIP, 0, (GLsizei)nVertices); FKLog("开启顶部光照显示"); }
bool CardBase::ccTouchBegan(CCTouch* touch, CCEvent* event) { glLineWidth(16); ccDrawColor4B(255,0,0,255); CCPoint vertices[] = { ccp(0, 0), ccp(50, 50), ccp(100, 50), ccp(100, 100) }; ccDrawPoly(vertices, 4, true); //glLineWidth(16); //ccDrawColor4B(0, 255, 0, 255); //ccDrawCircle( VisibleRect::center(), 100, 0, 10, false); CCSize s = this->backGround->getContentSize(); CCDrawNode *draw = CCDrawNode::create(); addChild(draw, 10); // Draw polygons CCPoint points[] = { CCPoint(s.height/4,0), CCPoint(s.width,s.height/5), CCPoint(s.width/3*2,s.height) }; draw->drawPolygon(points, sizeof(points)/sizeof(points[0]), ccc4f(1,0,0,0.5), 0, ccc4f(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; }
//------------------------------------------------------------------ // // LayerTest2 // //------------------------------------------------------------------ void LayerTest2::onEnter() { LayerTest::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize(); CCLayerColor* layer1 = CCLayerColor::layerWithColorWidthHeight( ccc4f(255, 255, 0, 80), 100, 300); layer1->setPosition(CCPointMake(s.width/3, s.height/2)); layer1->setIsRelativeAnchorPoint(true); addChild(layer1, 1); CCLayerColor* layer2 = CCLayerColor::layerWithColorWidthHeight( ccc4f(0, 0, 255, 255), 100, 300); layer2->setPosition(CCPointMake((s.width/3)*2, s.height/2)); layer2->setIsRelativeAnchorPoint(true); addChild(layer2, 1); CCActionInterval* actionTint = CCTintBy::actionWithDuration(2, -255, -127, 0); CCActionInterval* actionTintBack = actionTint->reverse(); CCActionInterval* seq1 = (CCActionInterval*)CCSequence::actions( actionTint, actionTintBack, NULL); layer1->runAction(seq1); CCActionInterval* actionFade = CCFadeOut::actionWithDuration(2.0f); CCActionInterval* actionFadeBack = actionFade->reverse(); CCActionInterval* seq2 = (CCActionInterval*)CCSequence::actions(actionFade, actionFadeBack, NULL); layer2->runAction(seq2); }
NS_CC_EXT_BEGIN /* IMPORTANT - READ ME! This file sets pokes around in the private API a lot to provide efficient debug rendering given nothing more than reference to a Chipmunk space. It is not recommended to write rendering code like this in your own games as the private API may change with little or no warning. */ // 此文件采用了很多私有的API,用于调试中渲染物理空间。 不推荐这么做,私有api最不愿改动 static ccColor4F ColorForBody(cpBody *body) { if (cpBodyIsRogue(body) || cpBodyIsSleeping(body)) { return ccc4f(0.5f, 0.5f, 0.5f ,0.5f); } else if (body->CP_PRIVATE(node).idleTime > body->CP_PRIVATE(space)->sleepTimeThreshold) { return ccc4f(0.33f, 0.33f, 0.33f, 0.5f); } else { return ccc4f(1.0f, 0.0f, 0.0f, 0.5f); } }
void GameEntityView::doHeal() { CCParticleFire* heal = CCParticleFire::createWithTotalParticles(25); CCPoint point = CCPointMake( m_healthBar->getContentSize().width/2, 0 ); heal->setStartColor( ccc4f(1,1,1,1.0f) ); heal->setEndColor( ccc4f(1,1,1,1.0f) ); heal->setSpeed(10); heal->setStartSize(15); CCPoint posVar = heal->getPosVar(); posVar.y /= 2; heal->setPosVar( posVar ); heal->setPosition( point ); m_healthBar->addChild(heal); CCSequence* seq = CCSequence::create( CCDelayTime::create(0.5f), CCCallFunc::create(heal, callfunc_selector(CCParticleFire::stopSystem)), CCDelayTime::create(1.5f), CCRemoveSelf::create(true), NULL ); heal->runAction(seq); }
void drawTBars(Track *track,CCPoint * timelineTrackRatio,CCSize * timeLineSize,float * addtionalDistance) { float porcentMaxSize=0.2f; float maxSize=track->_entBar[0]->getWidth()*porcentMaxSize; float sizeReductor=0.0f; float barsWidth=track->_entBar[0]->getWidth()*timelineTrackRatio->x; //if(barsWidth>=maxSize) //sizeReductor=track->_entBar[0]->getWidth()- track->_entBar[0]->getWidth()*porcentMaxSize; sizeReductor=track->_entBar[0]->getWidth()*porcentMaxSize; ccColor4F color; float trackHeight=track->getHeight(); float newX,newY; for (int i=0;i<track->_entBar.size();i++) { if(track->_entBar[i]->getClassName()=="Bar") color=ccc4f(0.0f,1.0f,0.0f,0.80f); else if(track->_entBar[i]->getClassName()=="StartBar" || track->_entBar[i]->getClassName()=="EndBar") color=ccc4f(1.0f,1.0f,0.0f,0.80f); else color=ccc4f(0,0.392f,1.0f,0.80f); newX=(track->_entBar[i]->getPositionX()+*addtionalDistance)*timelineTrackRatio->x ; newY=track->_entBar[i]->getHeight()*timelineTrackRatio->y; /*ccDrawSolidRect(ccp(newX + sizeReductor/2,newY + trackHeight),ccp(newX + barsWidth -sizeReductor/2,trackHeight),color);*/ ccDrawSolidRect(ccp(newX + barsWidth/2 -sizeReductor/2,newY + trackHeight),ccp(newX + barsWidth/2 + sizeReductor/2,trackHeight),color); } }
//爆炸后的粒子效果 CCParticleSystem* Bomb::createParticle() { ResManager* manager = ResManager::getManager(); CCParticleSystem* m_emitter = new CCParticleFire(); m_emitter->initWithTotalParticles(50); m_emitter->setBlendAdditive(false); m_emitter->setAutoRemoveOnFinish(true); m_emitter->setDuration(0.5f); m_emitter->setTexture( CCTextureCache::sharedTextureCache()->addImage(manager->getSharedFilePath(g_gameinPath+"fire.png").c_str())); m_emitter->setPosVar(ccp(60,60)); m_emitter->setStartColor(ccc4f(0.8f,0.8f,0.8f,0.1f)); m_emitter->setEndColor(ccc4f(0.1f,0.1f,0.1f,0.06f)); m_emitter->setEndColorVar(ccc4f(0.0f,0.0f,0.0f,0.0f)); m_emitter->setLife(0.8f); m_emitter->setLifeVar(0.3f); m_emitter->setSpeed(30.0f); m_emitter->setSpeedVar(20.0f); m_emitter->setScale(getScale()); m_emitter->autorelease(); return m_emitter; }
void ArtGameSquare::drawSquare(int col, int row, std::string artFile, Size size, Point scale, int artCols, int artRows) { _artRows = artRows; _neighbors[ArtBoxSide::TOP] = false; _neighbors[ArtBoxSide::BOTTOM] = false; _neighbors[ArtBoxSide::LEFT] = false; _neighbors[ArtBoxSide::RIGHT] = false; removeAllChildrenWithCleanup(true); _originalCol = col; _originalRow = row; _pieceSize = size; _color = Color(rand() % (int)Color::COUNT); _scale = scale; float innerWidth = _pieceSize.width * 0.4f; float innerHeight = _pieceSize.height * 0.4f; _image = CCSprite::create(artFile, CCRectMake(col * _pieceSize.width / _scale.x, (_artRows - (row + 1)) * _pieceSize.height / _scale.y, _pieceSize.width / _scale.x, _pieceSize.height / _scale.y)); _image->setScale(scale.x, scale.y); _arrow = CCSprite::create("hintLeft.png"); float arrowHeight = 24 * G_assetScale; _arrow->setScale(arrowHeight / _arrow->getContentSize().height); _arrow->setVisible(false); Point blPoint = Point(-_pieceSize.width * 0.5f, -_pieceSize.height * 0.5f); Point brPoint = Point(_pieceSize.width * 0.5f, -_pieceSize.height * 0.5f); Point tlPoint = Point(-_pieceSize.width * 0.5f, _pieceSize.height * 0.5f); Point trPoint = Point(_pieceSize.width * 0.5f, _pieceSize.height * 0.5f); //draw the 4 border lines _sides[ArtBoxSide::TOP] = DrawNode::create(); _sides[ArtBoxSide::TOP]->drawSegment(tlPoint, trPoint, 1, Color4F::BLACK); _sides[ArtBoxSide::BOTTOM] = DrawNode::create(); _sides[ArtBoxSide::BOTTOM]->drawSegment(blPoint, brPoint, 1, Color4F::BLACK); _sides[ArtBoxSide::LEFT] = DrawNode::create(); _sides[ArtBoxSide::LEFT]->drawSegment(tlPoint, blPoint, 1, Color4F::BLACK); _sides[ArtBoxSide::RIGHT] = DrawNode::create(); _sides[ArtBoxSide::RIGHT]->drawSegment(trPoint, brPoint, 1, Color4F::BLACK); _cover = DrawNode::create(); //draw the outer box Point points[] = { blPoint, tlPoint, trPoint, brPoint }; _cover->drawPolygon(points, 4, ccc4f(0.96f, 0.96f, 0.96f, 0.8f), 0, ccc4f(0.86f, 0.86f, 0.86f, 0.8f)); //draw the inner box Point innerPoints[] = { Point(-innerWidth * 0.5f, -innerHeight * 0.5f), Point(innerWidth * 0.5f, -innerHeight * 0.5f), Point(innerWidth * 0.5f, innerHeight * 0.5f), Point(-innerWidth * 0.5f, innerHeight * 0.5f) }; _cover->drawPolygon(innerPoints, 4, colorToCCColor(_color), 0, ccc4f(0.86f, 0.86f, 0.86f, 0.9f)); addChild(_image); addChild(_arrow); addChild(_sides[ArtBoxSide::LEFT]); addChild(_sides[ArtBoxSide::RIGHT]); addChild(_sides[ArtBoxSide::TOP]); addChild(_sides[ArtBoxSide::BOTTOM]); addChild(_cover); }
void HelloWorld::ccTouchMoved (CCTouch *pTouch, CCEvent *pEvent) { line.hexagones.erase (line.hexagones.begin() + 1, line.hexagones.end()); Hexagon h = field.CCP2Hex (this->convertTouchToNodeSpace (pTouch)); h.Integerlize(); line.MakeLine (line.hexagones[0], h, ccc4f (1, 0.5, 0.5, 1)); intersection.hexagones.clear(); intersection.MakeSolidHex (3, h, ccc4f (1, 1, 1, 1)); }
void ArtGameSquare::cover() { int borderWidth = 6; float bW = (_pieceSize.width - borderWidth) * 0.5f; float bH = (_pieceSize.height - borderWidth) * 0.5f; _cover = DrawNode::create(); Point points[] = { Point(-bW, -bH), Point(bW, -bH), Point(bW, bH), Point(-bW, bH) }; _cover->drawPolygon(points, 4, ccc4f(0.96f, 0.96f, 0.96f, 0.0f), borderWidth, ccc4f(0.86f, 0.86f, 0.86f, 0.7f)); addChild(_cover); _cover->setPosition(_image->getPosition()); }
void Optics2::drawLine(Ref *pSender) { if (lightOn) { node->clear(); lightOn=false; } else { lightOn=true; int objX = cannonX; int objY = cannonY; auto dir = cannon->firstDirection(); node = CCDrawNode::create(); addChild(node,10); while (dir!= GameObject::END && dir!=GameObject::WIN) { switch (dir) { case GameObject::UP : node->drawSegment(grid[objX][objY]->getPosition(), grid[objX][objY--]->getPosition(), 5.0,ccc4f(180,180,180,100)); dir = grid[objX][objY]->nextDirection(dir); break; case GameObject::DOWN : node->drawSegment(grid[objX][objY]->getPosition(), grid[objX][objY++]->getPosition(), 5.0,ccc4f(180,180,180,100)); dir = grid[objX][objY]->nextDirection(dir); break; case GameObject::LEFT : node->drawSegment(grid[objX][objY]->getPosition(), grid[objX++][objY]->getPosition(), 5.0,ccc4f(180,180,180,100)); dir = grid[objX][objY]->nextDirection(dir); break; case GameObject::RIGHT : node->drawSegment(grid[objX][objY]->getPosition(), grid[objX--][objY]->getPosition(), 5.0,ccc4f(180,180,180,100)); dir = grid[objX][objY]->nextDirection(dir); break; }//switch }//while if (dir==GameObject::WIN) showWin(); } }
bool PowerUp::init(GameWorld* instance) { if(!CCDrawNode::init()) return false; game_world_ = instance; time_left_ = MAX_POWERUP_WAIT_ON_SCREEN / 2 + CCRANDOM_0_1() * MAX_POWERUP_WAIT_ON_SCREEN / 2; speed_ = CCPoint(CCRANDOM_MINUS1_1() * 2, CCRANDOM_MINUS1_1() * 2); drawDot(CCPointZero, POWERUP_ICON_OUTER_RADIUS, ccc4f(0.73725f, 0.5451f, 0, 1)); drawDot(CCPointZero, POWERUP_ICON_OUTER_RADIUS - 3, ccc4f(0, 0, 0, 1)); setScale(0.0f); return true; }
bool CircleObject::init() { setIsDrag(false); setObjectType(ObjectType::CIRCLE_OBJECT); setTypeName("CircleObject"); m_drawnode = CCDrawNode::create(); addChild(m_drawnode); registerWithTouchDispatcher(); setBorderColor(ccc4f(1, 0, 0, 1)); setFillColor(ccc4f(0.5, 0.5, 0.5, 0.5)); m_radius = 10; return true; }
NS_CC_BEGIN // implementation CARenderImage CARenderImage::CARenderImage() : m_pImageView(NULL) , m_uFBO(0) , m_uDepthRenderBufffer(0) , m_nOldFBO(0) , m_pImage(0) , m_ePixelFormat(CAImage::PixelFormat_RGBA8888) , m_uClearFlags(0) , m_sClearColor(ccc4f(0,0,0,1)) , m_fClearDepth(0.0f) , m_nClearStencil(0) , m_bAutoDraw(false) , m_uPixelsWide(0) , m_uPixelsHigh(0) , m_uName(0) { #if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID // Listen this event to save render Image before come to background. // Then it can be restored after coming to foreground on Android. CANotificationCenter::sharedNotificationCenter()->addObserver(this, callfuncO_selector(CARenderImage::listenToBackground), EVENT_COME_TO_BACKGROUND, NULL); CANotificationCenter::sharedNotificationCenter()->addObserver(this, callfuncO_selector(CARenderImage::listenToForeground), EVENT_COME_TO_FOREGROUND, // this is misspelt NULL); #endif }
NS_CC_BEGIN // implementation CCRenderTexture CCRenderTexture::CCRenderTexture() : m_pSprite(NULL) , m_uFBO(0) , m_uDepthRenderBufffer(0) , m_nOldFBO(0) , m_pTexture(0) , m_pTextureCopy(0) , m_pUITextureImage(NULL) , m_ePixelFormat(kCCTexture2DPixelFormat_RGBA8888) , m_uClearFlags(0) , m_sClearColor(ccc4f(0,0,0,0)) , m_fDlearDepth(0.0f) , m_nClearStencil(0) , m_bAutoDraw(false) { // Listen this event to save render texture before come to background. // Then it can be restored after coming to foreground on Android. CCNotificationCenter::sharedNotificationCenter()->addObserver(this, callfuncO_selector(CCRenderTexture::listenToBackground), EVENT_COME_TO_BACKGROUND, NULL); }
bool ItemListScene::init() { bool result = GradientLayer::init(); if (result) { setTitle(MessageItemBookTitle); _items = GameEngine::sharedEngine()->getItems(); CCSize windowSize = CCDirector::sharedDirector()->getWinSize(); CCTableView *tableView = CCTableView::create(this, CCSize(windowSize.width, windowSize.height - TitleBarHeight)); tableView->setDirection(kCCScrollViewDirectionVertical); tableView->setDelegate(this); tableView->setBounceable(false); tableView->reloadData(); this->addChild(tableView); _scrollViewIndicator = CCDrawNode::create(); _scrollViewIndicator->drawSegment(ccp(windowSize.width - kScrollViewIndicatorMarginRight, windowSize.height), ccp(windowSize.width - kScrollViewIndicatorMarginRight, windowSize.height - kScrollViewIndicatorHeight), kScrollViewIndicatorRadius, ccc4f(1.0, 1.0, 1.0, 0.3)); _scrollViewIndicator->setPosition(ccp(0, -TitleBarHeight - kScrollViewIndicatorMarginVertical)); this->addChild(_scrollViewIndicator); setTitleBarLeftButton(MessageBackButtonTitle, GameEngine::sharedEngine(), menu_selector(GameEngine::showTitle)); } return result; }
bool TipLayer::initTipLayer() { CCSize winSize = CCDirector::sharedDirector()->getWinSize(); CCLayerColor *maskLayer = CCLayerColor::node(); maskLayer->initWithColorWidthHeight(ccc4f(0x00,0x00,0x00,0x80),335,350); //maskLayer->setOpacity(200); maskLayer->setAnchorPoint(ccp(0.5, 0.5)); maskLayer->setPosition(ccp(winSize.width/2-maskLayer->getContentSize().width/2, winSize.height/2-maskLayer->getContentSize().height/2)); this->addChild(maskLayer); /*CCSprite *bgSprite = CCSprite::spriteWithFile("actor_pause_bg.png"); this->addChild(bgSprite); bgSprite->setPosition(ccp(winSize.width / 2, winSize.height / 2));*/ std::string stdNameOne = ""; std::string stdNameTwo = ""; std::string contentImageName = ""; stdNameOne = s_touchfile + s_language + "actor_btn_cancel.png"; stdNameTwo = s_touchfile + s_language + "actor_btn_confirm.png"; contentImageName = s_language + "actor_img_tipContent.png"; //content CCSprite *pContentSprite = CCSprite::spriteWithFile(contentImageName.c_str()); this->addChild(pContentSprite); pContentSprite->setPosition(ccp(winSize.width / 2, winSize.height / 2 +100)); CCMenuItemImage *cancelItem = CCMenuItemImage::itemFromNormalImage(stdNameOne.c_str(), stdNameOne.c_str(), this, menu_selector(TipLayer::cancel)); CCMenuItemImage *confirmItem = CCMenuItemImage::itemFromNormalImage(stdNameTwo.c_str(), stdNameTwo.c_str(), this, menu_selector(TipLayer::confirm)); CCMenu *menu = CCMenu::menuWithItems(confirmItem,cancelItem,NULL); menu->alignItemsVertically(); menu->setPosition(ccp(winSize.width / 2, winSize.height / 2 - 50)); this->addChild(menu); CCLayer::setIsKeypadEnabled(true); return true; }
void ActionEllipse::update(float dt) { //t [0, 1] if (_target){ float x = getEllipsePositionX(dt); float y = getEllipsePositionY(dt); Point newPosition = _config.center + Point(x, y); //由于我们画计算出的椭圆你做值是以原点为中心的,所以需要加上我们设定的中心点坐标 _target->setPosition(_config.center + Point(x, y)); if (dt <= 0.5){ _target->setLocalZOrder(_config.zOrder.first); } else{ _target->setLocalZOrder(_config.zOrder.second); } #if 0 CCDrawNode *node = CCDrawNode::create(); node->drawDot(newPosition, 0.5f, ccc4f(17, 128,18, 60)); _target->getParent()->addChild(node); #endif } }
void CC3PODLight::initAtIndex( GLint aPODIndex, CC3PODResource* aPODRez ) { super::initAtIndex( aPODIndex, aPODRez ); // Get the light content if (getPodContentIndex() >= 0) { SPODLight* psl = (SPODLight*)aPODRez->getLightPODStructAtIndex(getPodContentIndex()); //LogRez(@"Setting %@ parameters from %@", [self class], NSStringFromSPODLight(psl)); setPodTargetIndex( psl->nIdxTarget ); setAmbientColor( kCC3DefaultLightColorAmbient ); setDiffuseColor( ccc4f(psl->pfColour[0], psl->pfColour[1], psl->pfColour[2], 1.0) ); setSpecularColor( kCC3DefaultLightColorSpecular ); setAttenuation( CC3AttenuationCoefficientsMake(psl->fConstantAttenuation, psl->fLinearAttenuation, psl->fQuadraticAttenuation) ); switch (psl->eType) { case ePODDirectional: setIsDirectionalOnly( true ); break; case ePODPoint: setIsDirectionalOnly( false ); break; case ePODSpot: setIsDirectionalOnly( false ); setSpotCutoffAngle( CC3RadToDeg(psl->fFalloffAngle) ); setSpotExponent( psl->fFalloffExponent ); break; default: break; } } }
void Enemy::draw(Renderer *renderer, const kmMat4& transform, bool transformUpdated) { Point myPosition = _spritePosition; ccDrawSolidRect(ccp(myPosition.x + HEALTH_BAR_ORIGIN, myPosition.y + 16), ccp(myPosition.x + HEALTH_BAR_ORIGIN + HEALTH_BAR_WIDTH, myPosition.y + 14), ccc4f(1.0, 0, 0, 1.0)); ccDrawSolidRect(ccp(myPosition.x + HEALTH_BAR_ORIGIN, myPosition.y + 16), ccp(myPosition.x + HEALTH_BAR_ORIGIN + (float)(_currentHp * HEALTH_BAR_WIDTH) / _maxHp, myPosition.y + 14), ccc4f(0, 1.0, 0, 1.0)); }
void Planta::draw(void) { // ccDrawPoly(vs, 4+fase*2, true); int i; int fasestodraw=((fase>3)?3:fase); for (i=0;i<=fasestodraw;i++) { ccDrawSolidPoly(&(draw_vs[4*i]), 4, ccc4f(0, 0.7+0.1*i, 0, 1)); } }
NS_PIX2D_BEGIN TextureSprite::TextureSprite() : mTime(CCPointZero) , mTexture2D(nullptr) { mColor = ccc4f(1.f, 1.f, 1.f, 1.f); }
void NDUIXBoardHitProxy::Initialization() { NDUILayer::Initialization(); m_kTouchDownLocalPos = CCPointZero; m_pkTouchDownView = NULL; m_kDebugColor = ccc4f(1.0f, 1.0f, 1.0f, 1.0f); //white }
/** A shadow volume only uses a material when it is to be visible during development. */ void CC3ShadowVolumeMeshNode::checkShadowMaterial() { if ( !_shouldDrawTerminator && isVisible() ) { setColor( CCColorRefFromCCC4F(ccc4f(kCC3OneThird, kCC3OneThird, kCC3OneThird, 1.0)) ); // Will lazily init material if needed setOpacity( (CCOpacity)(kCCOpacityFull * kCC3OneThird) ); } else setMaterial( NULL ); }
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)); }