在微信小游戏中使用粒子效果

参考:

1. 粒子库下载地址

2. 粒子官方使用教程

3. 水友解决微信小游戏particle is not defined

 

 

一、下载第三方库

Git地址:https://github.com/egret-labs/egret-game-library

 

二、配置粒子库

粒子库放在项目同级目录mylibs下

Particle 粒子效果使用(适配微信小游戏,particle is not defined)

 

 修改egretProperties.json文件

Particle 粒子效果使用(适配微信小游戏,particle is not defined)

 

编译一遍引擎

 

三、代码里使用粒子

 将Egret Feather制作的粒子资源放入项目

Particle 粒子效果使用(适配微信小游戏,particle is not defined)

 

适配微信小游戏,修改wxgame.ts,增加

                if (filename == 'libs/modules/particle/particle.js' || filename == 'libs/modules/particle/particle.min.js') {
                    content += ';window.particle = particle';
                }

Particle 粒子效果使用(适配微信小游戏,particle is not defined)

 

 如果不修改wxgame.ts,则会报下面的错

Particle 粒子效果使用(适配微信小游戏,particle is not defined)

 

代码中使用粒子

	//获取粒子资源
        var texture = RES.getRes("test_png");
        var config = RES.getRes("test_json");
        
        //新建粒子效果
        var fireStar:particle.GravityParticleSystem = new particle.GravityParticleSystem(texture, config);
        this.addChild(fireStar);
        fireStar.start();
        fireStar.x = 200;
        fireStar.y = 300;

  

效果如下

Particle 粒子效果使用(适配微信小游戏,particle is not defined)

 

相关文章:

  • 2021-11-04
  • 2021-05-27
  • 2021-05-28
  • 2021-12-19
  • 2021-06-16
  • 2021-12-31
  • 2021-07-23
  • 2022-12-23
猜你喜欢
  • 2021-05-02
  • 2021-09-08
  • 2022-12-23
  • 2021-04-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案