• cocos2d-x的初步学习五


    这一章中,我们来介绍下粒子系统,通过粒子,我们可以实现很酷的效果,特效等。OK,还是直接上代码:

     cocos2d::CCParticleSystemQuad *particle;
        
        particle=CCParticleSystemQuad::create("comet.plist");
        
        particle->setPosition(ccp(100, 200));
        
        this->addChild(particle, 1);
    

    CCParticleSystemQuad,矩形粒子,点粒子CCParticleSystemPoint应该是没了,这里我都是通过粒子编辑器直接生成了plist文件,通过加载plist来创建粒子,是不是很方便。。。^_^,OK,看效果图

    现在,我们换个粒子,通过触摸点来移动它看看:

    首先开启触摸

    this->setTouchEnabled(true);

    然后重写touchmove事件

    void HelloWorld::ccTouchesMoved(CCSet *touchs, CCEvent *event)
    {
    
        //获取触点指针容器中第一个元素
        CCSetIterator it=touchs->begin();
        //将其转化为触点信息
        CCTouch *touch=(CCTouch *)(*it);
        
        CCPoint touchLocation=touch->getLocation();
        
        
      //  touchLocation=CCDirector::sharedDirector()->convertToGL(touchLocation);
        
        
        
        particle->setPosition(ccp(touchLocation.x, touchLocation.y));
        
    
    
    }
    

    OK,就这么简单,看效果图:

     

  • 相关阅读:
    spring mongodb查询
    spring mongodb分页,动态条件、字段查询
    js导航下拉菜单
    spring mongodb增删改查操作
    组件
    vue的基本指令
    远程连接MongoDB数据库
    webpack工具、Vue、react模块化
    layui
    anaconda使用,jupyter notebook的使用方法
  • 原文地址:https://www.cnblogs.com/henrendadi/p/3141470.html
Copyright © 2020-2023  润新知