我有一个图像铃。我希望它能够被动画化,使其从右到左,从左到右无限期。我尝试了以下编码,但我无法实现它:
var curWin = Ti.UI.createWindow;
var nButto = Ti.UI.createButton({
backgroundImage : "/images/bell.png",
height : 29,
width : 29,
top : 0,
enabled : false,
textAlign : Titanium.UI.TEXT_ALIGNMENT_RIGHT,
font : {
fontFamily : 'OpenSans-Regular',
fontSize : 17
}
});
curWin.add(nButto);
var matrix = Ti.UI.create2DMatrix();
matrix = matrix.rotate(90);
var a = Ti.UI.createAnimation({
transform : matrix,
duration : 500,
autoreverse : true,
repeat : 0,
curve : Ti.UI.ANIMATION_CURVE_EASE_IN_OUT ,
});
var matrix1 = Ti.UI.create2DMatrix();
matrix1 = matrix.rotate(180);
var a1 = Ti.UI.createAnimation({
transform : matrix1,
duration : 500,
autoreverse : true,
repeat : 0,
curve : Ti.UI.ANIMATION_CURVE_EASE_IN_OUT ,
});
nButto.animate(a);
nButto.animate(a1);
nButto.anchorPoint = {
x : 0.5,
y : 0.5
};
答案 0 :(得分:1)
您可以向两个动画添加一个eventListener,在完整的侦听器中调用动画2,在2的侦听器中调用1。
a.addEventListener('complete',function(e){
//your code for callback function here.
});