zoukankan      html  css  js  c++  java
  • cocos2d-x树结构执行动作

    void Test2::onEnter()
    {
        TestCocosNodeDemo::onEnter();
    
        CCSize s = CCDirector::sharedDirector()->getWinSize();
        
        CCSprite *sp1 = CCSprite::create(s_pPathSister1);
        CCSprite *sp2 = CCSprite::create(s_pPathSister2);
        CCSprite *sp3 = CCSprite::create(s_pPathSister1);
        CCSprite *sp4 = CCSprite::create(s_pPathSister2);
        
        sp1->setPosition(ccp(100, s.height /2 ));
        sp2->setPosition(ccp(380, s.height /2 ));
        addChild(sp1);
        addChild(sp2);
        
        sp3->setScale(0.25f);
        sp4->setScale(0.25f);
        //把sp1和sp2当做父节点
        sp1->addChild(sp3);
        sp2->addChild(sp4);
        
        CCActionInterval* a1 = CCRotateBy::create(2, 360);
        CCActionInterval* a2 = CCScaleBy::create(2, 2);
        
        CCAction* action1 = CCRepeatForever::create(
                                                        (CCActionInterval*)(CCSequence::create(a1, a2, a2->reverse(), NULL))
                                                    );
        CCAction* action2 = CCRepeatForever::create(
                                                        (CCActionInterval*)(CCSequence::create(
                                                                                            (CCActionInterval*)(a1->copy()->autorelease()), 
                                                                                            (CCActionInterval*)(a2->copy()->autorelease()), 
                                                                                            a2->reverse(), 
                                                                                            NULL) )
                                                    );
        
        sp2->setAnchorPoint(ccp(0,0));
        //直接对父节点执行动作,子节点也会跟着执行
        sp1->runAction(action1);
        sp2->runAction(action2);
    }
  • 相关阅读:
    List<string>里的集合和字符串互转
    黑马程序员学习9
    黑马程序员学习7
    黑马程序员学习11
    黑马程序员学习10
    黑马程序员学习8
    黑马程序员学习12
    为什么Huffman编码不会发生冲突
    mule esb 配置maven 何苦
    php实现kafka功能开发 何苦
  • 原文地址:https://www.cnblogs.com/newlist/p/3215179.html
Copyright © 2011-2022 走看看