示例#1
0
// LayerIgnoreAnchorPointScale
void LayerIgnoreAnchorPointScale::onEnter()
{
    LayerTest::onEnter();
    
    CCSize s = CCDirector::sharedDirector()->getWinSize();

    CCLayerColor *l = CCLayerColor::create(ccc4(255, 0, 0, 255), 200, 200);

    l->setAnchorPoint(ccp(0.5f, 1.0f));
    l->setPosition(ccp( s.width/2, s.height/2));


    CCScaleBy *scale = CCScaleBy::create(2, 2);
    CCScaleBy* back = (CCScaleBy*)scale->reverse();
    CCSequence *seq = CCSequence::create(scale, back, NULL);

    l->runAction(CCRepeatForever::create(seq));

    this->addChild(l, 0, kLayerIgnoreAnchorPoint);

    CCSprite *child = CCSprite::create("Images/grossini.png");
    l->addChild(child);
    CCSize lsize = l->getContentSize();
    child->setPosition(ccp(lsize.width/2, lsize.height/2));

    CCMenuItemFont *item = CCMenuItemFont::create("Toogle ignore anchor point", this, menu_selector(LayerIgnoreAnchorPointScale::onToggle));

    CCMenu *menu = CCMenu::create(item, NULL);
    this->addChild(menu);

    menu->setPosition(ccp(s.width/2, s.height/2));
}
CCScaleBy* CCScaleBy::actionWithDuration(ccTime duration, float sx, float sy)
{
	CCScaleBy *pScaleBy = new CCScaleBy();
	pScaleBy->initWithDuration(duration, sx, sy);
	pScaleBy->autorelease();

	return pScaleBy;
}
//
// ScaleBy
//
CCScaleBy* CCScaleBy::actionWithDuration(cocos2d::ccTime duration, float s)
{
	CCScaleBy *pScaleBy = new CCScaleBy();
	pScaleBy->initWithDuration(duration, s);
	pScaleBy->autorelease();

	return pScaleBy;
}
CCAction *SudokuActionManager::createRoateScaleAction(){
    
    CCScaleBy *scale = CCScaleBy::create(0.5,1.5);
    CCRotateBy *rotate2 = CCRotateBy::create(1.0,360);
    CCSequence *sequence = CCSequence::create(scale,scale->reverse(),NULL);
    CCSpawn *roateScaleAction = CCSpawn::create(sequence,rotate2,NULL);
    return roateScaleAction;
}
CCScaleBy* CCScaleBy::create(float duration, float sx, float sy)
{
	CCScaleBy *pScaleBy = new CCScaleBy();
	pScaleBy->initWithDuration(duration, sx, sy);
	pScaleBy->autorelease();

	return pScaleBy;
}
示例#6
0
// 闪光动画
void Effect::spark(CCPoint pos, CCNode *parent, float scale, float duration)
{
    // spark 精灵
    CCSprite *one = CCSprite::create(s_explode1);
    CCSprite *two = CCSprite::create(s_explode2);
    CCSprite *three = CCSprite::create(s_explode3);
    
    // 混合模式
    ccBlendFunc cb = { GL_SRC_ALPHA, GL_ONE };
    one->setBlendFunc(cb);
    two->setBlendFunc(cb);
    three->setBlendFunc(cb);
    
    one->setPosition(pos);
    two->setPosition(pos);
    three->setPosition(pos);
    
    parent->addChild(one);
    parent->addChild(two);
    parent->addChild(three);
    
    one->setScale(scale);
    two->setScale(scale);
    three->setScale(scale);
    
    three->setRotation(CCRANDOM_0_1() * 360);
    
    CCRotateBy *left = CCRotateBy::create(duration, -45);
    CCRotateBy *right = CCRotateBy::create(duration, 45);
    CCScaleBy *scaleBy = CCScaleBy::create(duration, 3);
    CCFadeOut *fadeOut = CCFadeOut::create(duration);
    

    //JS写这个地方真是爽,这里却要写3个回调和3个动作
    CCCallFuncN *removeOne =  CCCallFuncN::create(this, callfuncN_selector(Effect::killSprite));
    CCCallFuncN *removeTwo =  CCCallFuncN::create(this, callfuncN_selector(Effect::killSprite));
    CCCallFuncN *removeThree =  CCCallFuncN::create(this, callfuncN_selector(Effect::killSprite));
    CCAction *seqOne = CCSequence::create(fadeOut, removeOne, NULL);
    CCAction *seqTwo = CCSequence::create((CCFadeOut*)fadeOut->copy(), removeTwo, NULL);
    CCAction *seqThree = CCSequence::create((CCFadeOut*)fadeOut->copy(), removeThree, NULL);
    
    one->runAction(left);
    two->runAction(right);
    
    one->runAction(scaleBy);
    two->runAction((CCScaleBy*)scaleBy->copy());
    three->runAction((CCScaleBy*)scaleBy->copy());
    
    one->runAction(seqOne);
    two->runAction(seqTwo);
    three->runAction(seqThree);
    
    
}
示例#7
0
/**
* 动态设置条目的位置
*/
bool UISuperBag::setBagDynamicPos(UIItem * item,const CCPoint& sPos,const CCPoint& dPos)
{
	if (!item) return false;
	CCPoint srcPos = sPos;

	CCPoint destPos = dPos;
	if (!item->getParent())
	{
		this->addChild(item);
	}
	CCMoveTo *moveAction = CCMoveTo::create(1.5f,destPos);
	CCScaleBy *scaleTo = CCScaleBy::create(0.75f,1.3f);
	CCFiniteTimeAction * seq = CCSequence::create(scaleTo,scaleTo->reverse(),NULL);
	item->runAction(CCSpawn::create(moveAction,seq,NULL));
	return true;
}
示例#8
0
文件: Drop.cpp 项目: crazyboymx/games
void Drop::startWave()
{
	stopWave();
	if (!waveAction)
	{
		CCScaleBy* scale;
		waveAction = CCSequence::create(
			scale = CCScaleBy::create(0.2f, 1.3f),
			scale->reverse(),
			scale = CCScaleBy::create(0.2f, 1.2f),
			scale->reverse(),
			scale = CCScaleBy::create(0.2f, 1.1f),
			scale->reverse(),
			NULL);
		waveAction->retain();
	}
	runAction(waveAction);
}
示例#9
0
void TextureAsync::onEnter()
{
    TextureDemo::onEnter();

    m_nImageOffset = 0;

    CCSize size =CCDirector::sharedDirector()->getWinSize();

    CCLabelTTF *label = CCLabelTTF::create("Loading...", "Marker Felt", 32);
    label->setPosition(ccp( size.width/2, size.height/2));
    addChild(label, 10);

    CCScaleBy* scale = CCScaleBy::create(0.3f, 2);
    CCScaleBy* scale_back = (CCScaleBy*)scale->reverse();
    CCSequence* seq = (CCSequence*)CCSequence::create(scale, scale_back, NULL);
    label->runAction(CCRepeatForever::create(seq));

    scheduleOnce(schedule_selector(TextureAsync::loadImages), 1.0f);
}
示例#10
0
//------------------------------------------------------------------
//
// 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(&params);
	
    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);
}
示例#11
0
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)));
	}
}
示例#12
0
//------------------------------------------------------------------
//
// 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));
}
示例#14
0
CCAction* BasicTest::actionScale()
{
    CCScaleBy *scale = CCScaleBy::create(1.33f, 1.5f);
    return CCRepeatForever::create(CCSequence::create(scale, scale->reverse(), NULL));
}