• pixijs做粒子拖尾效果


    pixijs做粒子拖尾效果

       <script type="text/javascript">
     const app = new PIXI.Application({ backgroundColor: 0x1099bb });
    document.body.appendChild(app.view);
    
    let emitterContainer = new PIXI.Container();
    app.stage.addChild(emitterContainer);
    
    let emitter = new PIXI.particles.Emitter(
    
        // The PIXI.Container to put the emitter in
        // if using blend modes, it's important to put this
        // on top of a bitmap, and not use the root stage Container
        emitterContainer,
    
        // The collection of particle images to use
        [PIXI.Texture.from('https://eia.github.io/ironman/2021/demo/2020_10_10-2/particle.png')],
    
        // Emitter configuration, edit this to change the look
        // of the emitter
        {
            "alpha": {
                "start": 1,
                "end": 0
            },
            "scale": {
                "start": 0.1,
                "end": 0.01,
                "minimumScaleMultiplier": 1
            },
            "color": {
                "start": "#e4f9ff",
                "end": "#3fcbff"
            },
            "speed": {
                "start": 200,
                "end": 50,
                "minimumSpeedMultiplier": 1
            },
            "acceleration": {
                "x": 0,
                "y": 0
            },
            "maxSpeed": 0,
            "startRotation": {
                "min": 0,
                "max": 360
            },
            "noRotation": false,
            "rotationSpeed": {
                "min": 0,
                "max": 0
            },
            "lifetime": {
                "min": 0.2,
                "max": 0.8
            },
            "blendMode": "normal",
            "frequency": 0.001,
            "emitterLifetime": -1,
            "maxParticles": 500,
            "pos": {
                "x": 0,
                "y": 0
            },
            "addAtBack": false,
            "spawnType": "circle",
            "spawnCircle": {
                "x": 0,
                "y": 0,
                "r": 0
            }
        }
    );
    
    // Calculate the current time
    var elapsed = Date.now();
    
    
    // Start emitting
    emitter.emit = true;
    var xssx=0;
    var xssy=0;
    app.ticker.add((delta) => {
        xssx+=6
        xssy+=1
        var now = Date.now();
        // The emitter requires the elapsed
        // number of seconds since the last update
        emitter.update((now - elapsed) * 0.001);
        elapsed = now;
         //这个是设置粒子坐标 达到拖尾效果
          emitter.updateOwnerPos(xssx,xssy)
    
        // Should re-render the PIXI Stage
        // renderer.render(stage);
    });
            </script>

     https://pixijs.io/pixi-particles-editor/ 这个是粒子编辑器

  • 相关阅读:
    android的左右滑动效果实现-ViewFlipper
    ios学习之UISwipeGestureRecognizer手势识别
    iOS使用AVFoundation实现二维码扫描
    IOS开发之Core Location
    iOS中如何创建一个滑出式导航面板(1)
    消息推送之百度云推送Android集成与使用方法
    IOS开发之Storyboard应用
    用CocoaPods做iOS程序的依赖管理
    RelativeLayout 布局参数
    Android中获取应用程序(包)的信息-----PackageManager的使用
  • 原文地址:https://www.cnblogs.com/newmiracle/p/13859752.html
Copyright © 2020-2023  润新知