Titanium - animation is v. v. choppy

一笑奈何 提交于 2019-12-19 11:27:23

问题


So i have an image that i want to drop down the page.

Should the user click a button, the image will stop said dropping down the page.

I've used the eventListener 'complete' style to execute this... and it works, in a fashion. The problem is that the dropping down is choppy ~ irritatingly so.

Is there a more efficient way for titanium to do some form of simple animation?

Here is a code slice:

    ballAnimation = Ti.UI.createAnimation({
            top: ballDown.top + 0.01*heightOfScreen,
            duration: someSpeedHere
        }, function(){
            if (hasBeenPressed){
                return;
            }
            else if (!hasBeenPressed && ballAnimation.top > lowestPointForBall){
                someFunctionHere(); //this isn't part of the problem. 
            } 
        }
    );

    ballAnimation.addEventListener('complete', function(){
        if (hasBeenPressed){
            return;
        }
        else if (!hasBeenPressed && ballAnimation.top > lowestPointForBall){
            someFunctionHere(); //this isn't part of the problem. 
        } else {
            ballAnimation.top = ballAnimation.top + 0.01*heightOfScreen;
            ballDown.animate(ballAnimation);
        } 
    });

    ballDown.animate(ballAnimation);

回答1:


For animations it is advised to use a 2D matrix with a translation like this:

var translation = Titanium.UI.create2DMatrix(), deltaX, deltaY; // set the deltaX and deltaY according
translation = translation.translate(deltaX, deltaY);
ballDown.animate({
    transform : translation,
    duration : someSpeedHere
});


来源:https://stackoverflow.com/questions/16272610/titanium-animation-is-v-v-choppy

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!