当前位置: 首页>>代码示例>>C++>>正文


C++ CCAction::copy方法代码示例

本文整理汇总了C++中CCAction::copy方法的典型用法代码示例。如果您正苦于以下问题:C++ CCAction::copy方法的具体用法?C++ CCAction::copy怎么用?C++ CCAction::copy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCAction的用法示例。


在下文中一共展示了CCAction::copy方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: onEnter

//------------------------------------------------------------------
//
// SpriteProgressBarTintAndFade
//
//------------------------------------------------------------------
void SpriteProgressBarTintAndFade::onEnter()
{
    SpriteDemo::onEnter();

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

    CCProgressTo *to = CCProgressTo::create(6, 100);
    CCAction *tint = CCSequence::create(CCTintTo::create(1, 255, 0, 0),
                                         CCTintTo::create(1, 0, 255, 0),
                                         CCTintTo::create(1, 0, 0, 255),
                                         NULL);
    CCAction *fade = CCSequence::create(CCFadeTo::create(1.0f, 0),
                                         CCFadeTo::create(1.0f, 255),
                                         NULL);

    CCProgressTimer *left = CCProgressTimer::create(CCSprite::create(s_pPathSister1));
    left->setType(kCCProgressTimerTypeBar);

    //    Setup for a bar starting from the bottom since the midpoint is 0 for the y
    left->setMidpoint(ccp(0.5f, 0.5f));
    //    Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
    left->setBarChangeRate(ccp(1, 0));
    addChild(left);
    left->setPosition(ccp(100, s.height/2));
    left->runAction(CCRepeatForever::create((CCActionInterval *)to->copy()->autorelease()));
    left->runAction(CCRepeatForever::create((CCActionInterval *)tint->copy()->autorelease()));

    left->addChild(CCLabelTTF::create("Tint", "Marker Felt", 20.0f));

    CCProgressTimer *middle = CCProgressTimer::create(CCSprite::create(s_pPathSister2));
    middle->setType(kCCProgressTimerTypeBar);
    //    Setup for a bar starting from the bottom since the midpoint is 0 for the y
    middle->setMidpoint(ccp(0.5f, 0.5f));
    //    Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
    middle->setBarChangeRate(ccp(1, 1));
    addChild(middle);
    middle->setPosition(ccp(s.width/2, s.height/2));
    middle->runAction(CCRepeatForever::create((CCActionInterval *)to->copy()->autorelease()));
    middle->runAction(CCRepeatForever::create((CCActionInterval *)fade->copy()->autorelease()));

    middle->addChild(CCLabelTTF::create("Fade", "Marker Felt", 20.0f));

    CCProgressTimer *right = CCProgressTimer::create(CCSprite::create(s_pPathSister2));
    right->setType(kCCProgressTimerTypeBar);
    //    Setup for a bar starting from the bottom since the midpoint is 0 for the y
    right->setMidpoint(ccp(0.5f, 0.5f));
    //    Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
    right->setBarChangeRate(ccp(0, 1));
    addChild(right);
    right->setPosition(ccp(s.width-100, s.height/2));
    right->runAction(CCRepeatForever::create((CCActionInterval *)to->copy()->autorelease()));
    right->runAction(CCRepeatForever::create((CCActionInterval *)tint->copy()->autorelease()));
    right->runAction(CCRepeatForever::create((CCActionInterval *)fade->copy()->autorelease()));

    right->addChild(CCLabelTTF::create("Tint and Fade", "Marker Felt", 20.0f));
}
开发者ID:DangoXJ,项目名称:TuJinZhi,代码行数:61,代码来源:ActionsProgressTest.cpp

示例2:

//------------------------------------------------------------------
//
// Test5
//
//------------------------------------------------------------------
Test5::Test5()
{
	CCSprite* sp1 = CCSprite::spriteWithFile(s_pPathSister1);
	CCSprite* sp2 = CCSprite::spriteWithFile(s_pPathSister2);
	
	sp1->setPosition(CCPointMake(100,160));
	sp2->setPosition(CCPointMake(380,160));

	CCRotateBy* rot = CCRotateBy::actionWithDuration(2, 360);
	CCActionInterval* rot_back = rot->reverse();
	CCAction* forever = CCRepeatForever::actionWithAction(
													(CCActionInterval*)(CCSequence::actions(rot, rot_back, NULL)) 
												);
	CCAction* forever2 = (CCAction*)(forever->copy()->autorelease());
	forever->setTag(101);
	forever2->setTag(102);
												  
	addChild(sp1, 0, kTagSprite1);
	addChild(sp2, 0, kTagSprite2);
			
	sp1->runAction(forever);
	sp2->runAction(forever2);
	
	schedule( schedule_selector(Test5::addAndRemove), 2.0f);
}
开发者ID:issamux,项目名称:WebGame,代码行数:30,代码来源:CocosNodeTest.cpp

示例3: onEnter

void RotateWorldMainLayer::onEnter()
{
	CCLayer::onEnter();

	float x,y;
	
	CGSize size = CCDirector::sharedDirector()->getWinSize();
	x = size.width;
	y = size.height;
	
	CCNode* blue =  CCColorLayer::layerWithColor(ccc4(0,0,255,255));
	CCNode* red =   CCColorLayer::layerWithColor(ccc4(255,0,0,255));
	CCNode* green = CCColorLayer::layerWithColor(ccc4(0,255,0,255));
	CCNode* white = CCColorLayer::layerWithColor(ccc4(255,255,255,255));

	blue->setScale(0.5f);
	blue->setPosition(CGPointMake(-x/4,-y/4));
	blue->addChild( SpriteLayer::node() );
	
	red->setScale(0.5f);
	red->setPosition(CGPointMake(x/4,-y/4));

	green->setScale(0.5f);
	green->setPosition(CGPointMake(-x/4,y/4));
	green->addChild(TestLayer::node());

	white->setScale(0.5f);
	white->setPosition(CGPointMake(x/4,y/4));

	addChild(blue, -1);
	addChild(white);
	addChild(green);
	addChild(red);

	CCAction* rot = CCRotateBy::actionWithDuration(8, 720);
	
	blue->runAction(rot);
	red->runAction((CCAction *)(rot->copy()->autorelease()));
	green->runAction((CCAction *)(rot->copy()->autorelease()) );
	white->runAction((CCAction *)(rot->copy()->autorelease()) );
}
开发者ID:charlesa101,项目名称:cocos2d-x,代码行数:41,代码来源:RotateWorldTest.cpp

示例4: onEnter

//------------------------------------------------------------------
//
// ActionOrbit
//
//------------------------------------------------------------------
void ActionOrbit::onEnter()
{
    ActionsDemo::onEnter();

    centerSprites(3);

    CCActionInterval*  orbit1 = CCOrbitCamera::actionWithDuration(2,1, 0, 0, 180, 0, 0);
    CCFiniteTimeAction*  action1 = CCSequence::actions(
                                       orbit1,
                                       orbit1->reverse(),
                                       NULL);

    CCActionInterval*  orbit2 = CCOrbitCamera::actionWithDuration(2,1, 0, 0, 180, -45, 0);
    CCFiniteTimeAction*  action2 = CCSequence::actions(
                                       orbit2,
                                       orbit2->reverse(),
                                       NULL);

    CCActionInterval*  orbit3 = CCOrbitCamera::actionWithDuration(2,1, 0, 0, 180, 90, 0);
    CCFiniteTimeAction*  action3 = CCSequence::actions(
                                       orbit3,
                                       orbit3->reverse(),
                                       NULL);

    m_kathia->runAction(CCRepeatForever::actionWithAction((CCActionInterval*)action1));
    m_tamara->runAction(CCRepeatForever::actionWithAction((CCActionInterval*)action2));
    m_grossini->runAction(CCRepeatForever::actionWithAction((CCActionInterval*)action3));

    CCActionInterval*  move = CCMoveBy::actionWithDuration(3, CGPointMake(100,-100));
    CCActionInterval*  move_back = move->reverse();
    CCFiniteTimeAction*  seq = CCSequence::actions(move, move_back, NULL);
    CCAction*  rfe = CCRepeatForever::actionWithAction((CCActionInterval*)seq);
    m_kathia->runAction(rfe);
    m_tamara->runAction((CCAction*)(rfe->copy()->autorelease()));
    m_grossini->runAction((CCAction*)(rfe->copy()->autorelease()));
}
开发者ID:shootan,项目名称:Terraria,代码行数:41,代码来源:ActionsTest.cpp

示例5: ccp

//------------------------------------------------------------------
//
// Atlas3
//
//------------------------------------------------------------------
Atlas3::Atlas3()
{
	m_time = 0;

	CCColorLayer* col = CCColorLayer::layerWithColor( ccc4(128,128,128,255) );
	addChild(col, -10);
	
	CCBitmapFontAtlas* label1 = CCBitmapFontAtlas::bitmapFontAtlasWithString("Test",  "fonts/bitmapFontTest2.fnt");
	
	// testing anchors
	label1->setAnchorPoint( ccp(0,0) );
	addChild(label1, 0, kTagBitmapAtlas1);
	CCIntervalAction* fade = CCFadeOut::actionWithDuration(1.0f);
	CCIntervalAction* fade_in = fade->reverse();
	CCFiniteTimeAction* seq = CCSequence::actions(fade, fade_in, NULL);
	CCAction* repeat = CCRepeatForever::actionWithAction((CCIntervalAction*)seq);
	label1->runAction(repeat);
	

	// VERY IMPORTANT
	// color and opacity work OK because bitmapFontAltas2 loads a BMP image (not a PNG image)
	// If you want to use both opacity and color, it is recommended to use NON premultiplied images like BMP images
	// Of course, you can also tell XCode not to compress PNG images, but I think it doesn't work as expected
	CCBitmapFontAtlas *label2 = CCBitmapFontAtlas::bitmapFontAtlasWithString("Test", "fonts/bitmapFontTest2.fnt");
	// testing anchors
	label2->setAnchorPoint( ccp(0.5f, 0.5f) );
	label2->setColor( ccRED );
	addChild(label2, 0, kTagBitmapAtlas2);
	label2->runAction( (CCAction*)(repeat->copy()->autorelease()) );
	
	CCBitmapFontAtlas* label3 = CCBitmapFontAtlas::bitmapFontAtlasWithString("Test", "fonts/bitmapFontTest2.fnt");
	// testing anchors
	label3->setAnchorPoint( ccp(1,1) );
	addChild(label3, 0, kTagBitmapAtlas3);
	
	
	CGSize s = CCDirector::sharedDirector()->getWinSize();	
	label1->setPosition( ccp( 0,0) );
	label2->setPosition( ccp( s.width/2, s.height/2) );
	label3->setPosition( ccp( s.width, s.height) );

	schedule( schedule_selector(Atlas3::step) );//:@selector(step:)];
}
开发者ID:charlesa101,项目名称:cocos2d-x,代码行数:48,代码来源:AtlasTest.cpp

示例6: addChild

//------------------------------------------------------------------
//
// Atlas3
//
// Use any of these editors to generate BMFonts:
//     http://glyphdesigner.71squared.com/ (Commercial, Mac OS X)
//     http://www.n4te.com/hiero/hiero.jnlp (Free, Java)
//     http://slick.cokeandcode.com/demos/hiero.jnlp (Free, Java)
//     http://www.angelcode.com/products/bmfont/ (Free, Windows only)
//
//------------------------------------------------------------------
Atlas3::Atlas3()
{
    m_time = 0;

    CCLayerColor* col = CCLayerColor::create( ccc4(128,128,128,255) );
    addChild(col, -10);
    
    CCLabelBMFont* label1 = CCLabelBMFont::create("Test",  "fonts/bitmapFontTest2.fnt");
    
    // testing anchors
    label1->setAnchorPoint( ccp(0,0) );
    addChild(label1, 0, kTagBitmapAtlas1);
    CCActionInterval* fade = CCFadeOut::create(1.0f);
    CCActionInterval* fade_in = fade->reverse();
    CCSequence* seq = CCSequence::create(fade, fade_in, NULL);
    CCAction* repeat = CCRepeatForever::create(seq);
    label1->runAction(repeat);
    

    // VERY IMPORTANT
    // color and opacity work OK because bitmapFontAltas2 loads a BMP image (not a PNG image)
    // If you want to use both opacity and color, it is recommended to use NON premultiplied images like BMP images
    // Of course, you can also tell XCode not to compress PNG images, but I think it doesn't work as expected
    CCLabelBMFont *label2 = CCLabelBMFont::create("Test", "fonts/bitmapFontTest2.fnt");
    // testing anchors
    label2->setAnchorPoint( ccp(0.5f, 0.5f) );
    label2->setColor( ccRED );
    addChild(label2, 0, kTagBitmapAtlas2);
    label2->runAction( (CCAction*)(repeat->copy()->autorelease()) );
    
    CCLabelBMFont* label3 = CCLabelBMFont::create("Test", "fonts/bitmapFontTest2.fnt");
    // testing anchors
    label3->setAnchorPoint( ccp(1,1) );
    addChild(label3, 0, kTagBitmapAtlas3);
       
    label1->setPosition( VisibleRect::leftBottom() );
    label2->setPosition( VisibleRect::center() );
    label3->setPosition( VisibleRect::rightTop() );

    schedule( schedule_selector(Atlas3::step) );//:@selector(step:)];
}
开发者ID:GhostSoar,项目名称:Cocos2dWindows,代码行数:52,代码来源:LabelTest.cpp


注:本文中的CCAction::copy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。