【问题标题】:How to remove a tween with createjs如何使用 createjs 删除补间
【发布时间】:2016-01-19 05:55:36
【问题描述】:

我有一个作为计时器旋转的时钟指针。如果用户在时间用完之前完成了活动,我需要停止该补间。

我尝试删除补间但没有运气。我做错了什么?

我进入了我的升级功能,但移除补间不起作用。

 function Clock() {
            //    this.board = board;
            clockContainer = new createjs.Container();
            contain = new createjs.Container();
            var clockBack = new createjs.Bitmap(queue.getResult("clockBack"));
            clockHand = new createjs.Bitmap(queue.getResult("clockHand"));
            clockBack.x = 40;
            clockBack.y = 480;
            clockHand.x = 95;
            clockHand.y = 539;
            clockHand.regX = 20
            clockHand.regY = 105;
            clockHand.scaleX = clockHand.scaleY = 0.50;
            clockBack.scaleX = clockBack.scaleY = 0.50;
            clockContainer.addChild(clockBack, clockHand);
            TimerLength = 30000;
            stage.addChild(clockContainer)
            mytweentodisable = createjs.Tween.get(clockHand, { loop: false }).to({ rotation: 360 }, TimerLength).call(function () {
                //this will trigger the timer is up
                GamehasEnded = true;
                checkWrongAndRight();
            });
        }

  function levelUp() {

            createjs.Tween.removeTweens(mytweentodisable)
            console.log("adding Level up button");
            levelUpContainer = new createjs.Container();
            levelUpIcon = new createjs.Bitmap(queue.getResult("levelUp"));
            levelUpContainer.addChild(levelUpIcon);
            stage.addChild(levelUpContainer)
            levelUpContainer.x = 350
            levelUpContainer.y = 500
            levelUpContainer.addEventListener("click", function () {
                console.log("clicked it");
            });
        }

【问题讨论】:

    标签: javascript html5-canvas createjs tween tween.js


    【解决方案1】:

    这应该可以解决问题:

    mytweentodisable.setPaused(true);

    【讨论】:

    • 我老板是你的忠实粉丝!
    • 告诉他我打过招呼。 :)
    • 据我了解的实现,setPaused() 实际上从库内部删除了对补间的引用,因此如果用户也没有引用,补间将被垃圾收集。当我看到方法名称时,这对我来说并不明显。我正在寻找一个名为remove() 之类的实例方法。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-05-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-07
    • 1970-01-01
    相关资源
    最近更新 更多