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);
    }
  • 相关阅读:
    Node入门
    Java try-catch、throw和throws的几点想法
    SpringMVC的四种HandlerMapping
    枚举
    MyBatis表和实体关联
    MyBatis xml和dao层接口组合使用
    Spring Task 定时器
    (转)Spring定时任务的几种实现
    Struts2+Spring发送邮件
    Struts2文件上传
  • 原文地址:https://www.cnblogs.com/newlist/p/3215179.html
Copyright © 2011-2022 走看看