//------------------------------------------------------------------ // // TextureGlRepeat // //------------------------------------------------------------------ void TextureGlRepeat::onEnter() { TextureDemo::onEnter(); CCSize size = CCDirector::sharedDirector()->getWinSize(); // The .png image MUST be power of 2 in order to create a continue effect. // eg: 32x64, 512x128, 256x1024, 64x64, etc.. CCSprite *sprite = CCSprite::spriteWithFile("Images/pattern1.png", CCRectMake(0, 0, 4096, 4096)); addChild(sprite, -1, kTagSprite1); sprite->setPosition(ccp(size.width/2,size.height/2)); ccTexParams params = {CC_LINEAR,CC_LINEAR,CC_REPEAT,CC_REPEAT}; sprite->getTexture()->setTexParameters(¶ms); CCRotateBy* rotate = CCRotateBy::actionWithDuration(4, 360); sprite->runAction(rotate); CCScaleBy* scale = CCScaleBy::actionWithDuration(2, 0.04f); CCScaleBy* scaleBack = (CCScaleBy*) (scale->reverse()); CCFiniteTimeAction* seq = CCSequence::actions(scale, scaleBack, NULL); sprite->runAction(seq); }
void IOSStoreLayer::showStarsFadeEffect(CCNode* pBox) { int iStarCount = 8; CCPointArray* pPointArray = randStarPoint(iStarCount); for (int i = 0; i < iStarCount; ++i) { CCSprite* pStar = CCSprite::create(ResManager::getManager()->getSharedFilePath(g_storelayerPath+"daoju_baoxiang_xiaoguo_2.png").c_str()); pStar->setScale(this->randScale()); pStar->setRotation(this->randRotation()); pBox->addChild(pStar); CCPoint point = pPointArray->getControlPointAtIndex(i); pStar->setPosition(ccp(point.x , point.y)); pStar->setTag(box_star_tag); float dt = CCRANDOM_0_1() + 1.0f; float scale = CCRANDOM_0_1() + 0.5f; pStar->runAction(CCRepeatForever::create(CCSequence::create(CCFadeOut::create(dt), CCFadeIn::create(dt), NULL))); CCScaleBy* pscaleby = CCScaleBy::create(dt, scale); pStar->runAction(CCRepeatForever::create(CCSequence::create(pscaleby, pscaleby->reverse(), NULL))); } }
//------------------------------------------------------------------ // // TextureAlias // //------------------------------------------------------------------ void TextureAlias::onEnter() { TextureDemo::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize(); // // Sprite 1: GL_LINEAR // // Default filter is GL_LINEAR CCSprite *sprite = CCSprite::spriteWithFile("Images/grossinis_sister1.png"); sprite->setPosition(ccp( s.width/3.0f, s.height/2.0f)); addChild(sprite); // this is the default filterting sprite->getTexture()->setAntiAliasTexParameters(); // // Sprite 1: GL_NEAREST // CCSprite *sprite2 = CCSprite::spriteWithFile("Images/grossinis_sister2.png"); sprite2->setPosition(ccp( 2*s.width/3.0f, s.height/2.0f)); addChild(sprite2); // Use Nearest in this one sprite2->getTexture()->setAliasTexParameters(); // scale them to show CCScaleBy* sc = CCScaleBy::actionWithDuration(3, 8.0f); CCScaleBy* sc_back = (CCScaleBy*) (sc->reverse()); CCRepeatForever* scaleforever = CCRepeatForever::actionWithAction((CCActionInterval*) (CCSequence::actions(sc, sc_back, NULL))); CCRepeatForever* scaleToo = (CCRepeatForever*) (scaleforever->copy()); scaleToo->autorelease(); sprite2->runAction(scaleforever); sprite->runAction(scaleToo); CCTextureCache::sharedTextureCache()->dumpCachedTextureInfo(); }
//------------------------------------------------------------------ // // TileMapTest // //------------------------------------------------------------------ TileMapTest::TileMapTest() { CCTileMapAtlas* map = CCTileMapAtlas::create(s_TilesPng, s_LevelMapTga, 16, 16); // Convert it to "alias" (GL_LINEAR filtering) map->getTexture()->setAntiAliasTexParameters(); CCSize s = map->getContentSize(); CCLOG("ContentSize: %f, %f", s.width,s.height); // If you are not going to use the Map, you can free it now // NEW since v0.7 map->releaseMap(); addChild(map, 0, kTagTileMap); map->setAnchorPoint( ccp(0, 0.5f) ); CCScaleBy *scale = CCScaleBy::create(4, 0.8f); CCActionInterval *scaleBack = scale->reverse(); CCFiniteTimeAction* seq = CCSequence::create(scale, scaleBack, NULL); map->runAction(CCRepeatForever::create((CCActionInterval *)seq)); }
CCAction* BasicTest::actionScale() { CCScaleBy *scale = CCScaleBy::create(1.33f, 1.5f); return CCRepeatForever::create(CCSequence::create(scale, scale->reverse(), NULL)); }