zoukankan      html  css  js  c++  java
  • egret中场景跳转的动画

    原理:
    创建一个截取当前场景的截图
    然后对截图进行bitmap处理
    加上tween。
    优点:无需任何图片,特效!适用于任何场景!

    //1.卷帘特效
    //2.左右切换移动
    //3.直接翻
    //4.旋转掉落
    //5.随机一种
     
    调用:ScreenMovies.MovieStart(5);

    class ScreenMovies {
    //当前舞台
    static MovieStart(_txnums):void {
    //创建一个截图Bitmap
    let taget = MtwGame.Instance.stage;
    let w = MtwGame.Instance.stage.stageWidth;
    let h = MtwGame.Instance.stage.stageHeight;

    //新建一个group
    let loadTxGrp = new eui.Group();
    loadTxGrp.width = w;
    loadTxGrp.height = h;
    taget.addChild(loadTxGrp)

    //循环创建多个截图bitmap 这里num自由设置
    let tx1Number = 40;

    //每个横着的数量
    let Xnumber = 5;

    //高数量自动计算
    let Ynumber = tx1Number / Xnumber;

    if (_txnums == 5) {
    _txnums = Math.ceil(Math.random() * 4);
    }
    for (let i = 0; i < tx1Number; i++) {
    //计算每个的XY及宽高
    let _mcW = w / Xnumber;
    let _mcH = h / Ynumber;
    let _mcX = i % Xnumber * _mcW;
    let _mcY = Math.floor(i / Xnumber) * _mcH;

    let renderTexture: egret.RenderTexture = new egret.RenderTexture();
    renderTexture.drawToTexture(taget, new egret.Rectangle(_mcX, _mcY, _mcW, _mcH));
    let bmp = new egret.Bitmap;
    bmp.texture = renderTexture;
    bmp.anchorOffsetX = _mcW / 2
    bmp.anchorOffsetY = _mcH / 2
    bmp.x = _mcX + _mcW / 2;
    bmp.y = _mcY + _mcH / 2;

    loadTxGrp.addChild(bmp);

    let tw = egret.Tween.get(bmp);
    //开始特效
    switch (_txnums) {
    case 1:
    tw.to({ scaleX: 0, scaleY: 0, alpha: 0, rotation: 359 }, 800, egret.Ease.circIn).call(onComplete, this);
    break;
    case 2:
    let my_x = -w
    if (!(i % 2)) {
    my_x = w * 2
    }
    tw.to({ x: my_x, alpha: 0 }, 800, egret.Ease.circIn).call(onComplete, this);
    break;
    case 3:
    tw.to({ scaleX: 0.2, scaleY: 1, alpha: 0, blurFliter: 0 }, 800, egret.Ease.backInOut).call(onComplete, this);
    break;
    case 4:
    tw.to({ alpha: 0}, 900, egret.Ease.circIn).call(onComplete, this)
    break;
    default:
    tw.to({ scaleX: 1, scaleY: 0, alpha: 0 }, 800, egret.Ease.circIn).call(onComplete, this);
    }
    }
    let upNumber = 0;
    function onComplete(evt: Comment) {
    upNumber++
    if (upNumber == tx1Number) {
    taget.removeChild(loadTxGrp)
    }
    }
    }
    }

    ---------原文用的是AS3,我改成了TS,来自egret社区的sjavene

  • 相关阅读:
    欧拉工程第53题:Combinatoric selections
    540A: Combination Lock
    540C: Ice Cave
    540B :School Marks
    欧拉工程第52题:Permuted multiples
    欧拉工程第51题:Prime digit replacements
    C. Tourist's Notes
    B. Quasi Binary
    [LeetCode] Longest Substring Without Repeating Characters
    [hihoCoder] 后序遍历
  • 原文地址:https://www.cnblogs.com/jiajunjie/p/9117526.html
Copyright © 2011-2022 走看看