void SoulPrev::createFish(const CCPoint& point) { //use CCSpriteBachNode to draw texture CCTexture2D* texture = CCTextureCache::sharedTextureCache()->textureForKey("fish.png"); CCSpriteBatchNode* spbatch = CCSpriteBatchNode::createWithTexture(texture); spbatch->setPosition(ccp(0, 0)); this->addChild(spbatch); CCSprite* sprite = CCSprite::createWithSpriteFrameName("hudieyu_72.png"); sprite->setPosition(point); sprite->setPosition(point); spbatch->addChild(sprite); }
void HomeScene::__initLighting() { const int deg = 30; CCSpriteBatchNode *pLightingNode = CCSpriteBatchNode::createWithTexture(SPRITE("*****@*****.**")->getTexture()); for(int i=0; i<6; i++) { CCSprite *light = SPRITE("*****@*****.**"); light->setRotation(i*deg); light->setScale(2); pLightingNode->addChild(light); } ccBlendFunc cbl = {GL_DST_COLOR, GL_ONE}; pLightingNode->setBlendFunc(cbl); pLightingNode->setPosition(VisibleRect::center()); addChild(pLightingNode); //使光芒开始旋转 CCRotateBy *rotateAct = CCRotateBy::create(1,30); pLightingNode->runAction(CCRepeatForever::create(rotateAct)); }
bool StoryWorld::init() { if ( !CCLayer::init() ) { return false; } char theName[10][11]={"","穆婧:", "子轩:", "少杰:", "建国", "路人A:", "路人B:", "路人C:", "老爷爷:", "江姐:"}; char play[20] = SCRIPT_PATH; current=sGlobal->mapState->storyCnt+'0'; play[SCRIPT_PATH_LEN] = current; reader.ReadFileWithFullPath(CCFileUtils::sharedFileUtils()->fullPathForFilename(play)); this->setTouchEnabled(true); CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize(); CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin(); char bg_name[30] = "" ; char bg_num[4]=""; sprintf(bg_num, "%c00", current); sprintf(bg_name, BGNAME_IMG_PATH, bg_num); CCSprite *pBackground = CCSprite::createWithTexture(GET_TEXTURE(bg_name)); //CCSprite* pBackground = CCSprite::create(bg_name); pBackground->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y)); pBackground->setScale(1); pBackground->setTag(108); addChild(pBackground, 0); CCSprite* dialogBox = CCSprite::create(DUIHUAKUANG_IMG_PATH); dialogBox->setPosition(ccp(visibleSize.width/2, dialogBox->getContentSize().height/2)); dialogBox->setOpacity(220); addChild(dialogBox,1); CCLabelTTF* pName = CCLabelTTF::create(theName[0], "Heiti SC", 40); pName->setTag(101); pName->setPosition(ccp(pName->getContentSize().width/2, dialogBox->getContentSize().height - 2 * pName->getContentSize().height)); pName->setAnchorPoint(CCPointZero); addChild(pName, 1); CCLabelTTF* pLabel = CCLabelTTF::create("Click to Start", "Heiti SC", 40); pLabel->setTag(100); pLabel->setPosition(ccp(40, origin.y + dialogBox->getContentSize().height - 3.4 * pLabel->getContentSize().height)); pLabel->setAnchorPoint(CCPointZero); pLabel->setDimensions(CCSizeMake(1100, 0)); pLabel->setHorizontalAlignment(kCCTextAlignmentLeft); addChild(pLabel, 1); CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(PLIST_IMG_PATH); CCSpriteBatchNode *spriteBatch = CCSpriteBatchNode::createWithTexture(GET_TEXTURE(VDRAWING_IMG_PATH)); spriteBatch->setTag(102); addChild(spriteBatch, 0); spriteBatch->setPosition(CCPointZero); CCSprite *leftSprite=CCSprite::createWithSpriteFrameName("me_1.png"); leftSprite->setScale(0.8); leftSprite->setPosition(ccp(leftSprite->getContentSize().width*0.6, leftSprite->getContentSize().height/2 *0.8)); leftSprite->setTag(1); leftSprite->setOpacity(0); spriteBatch->addChild(leftSprite, 0); CCSprite *rightSprite=CCSprite::createWithSpriteFrameName("blank.png"); //rightSprite->setScale(0.8); rightSprite->setPosition(ccp(800, 130)); rightSprite->setTag(2); rightSprite->setOpacity(0); spriteBatch->addChild(rightSprite, 0); avgGame(); return true; }