moveTo callback function on for loop

9 views
Skip to first unread message

Iker Vázquez

unread,
Jul 8, 2013, 5:59:19 AM7/8/13
to caa...@googlegroups.com
Hi all!

I have the following code:

function createnumber(nombre, T) {
  var text = new CAAT.TextActor().
    setFont("200px sans-serif").
    setText(nombre). setAlign("center"). 
    cacheAsBitmap(). 
    setFrameTime(0, T + 1000). 
    addListener({ actorLifeCycleEvent: function(actor, event_type, time) { 
        if (event_type === 'expired' && (actor.del === 1)) { 
               actor.setFrameTime(time, 2000); 
               actor.moveTo((10000), (container.height / 2), 1000, 0); 
               actor.addBehavior(new CAAT.AlphaBehavior().setFrameTime(time, 600).setValues(1, 0)); actor.del = 0; } } 
     }); 
     text.del = 1; 
     return text; 
 }

var T = 1000; 
for (var x = numbers.length; x >= 1; x--){ 
    T = T + 1000; 
    var text = createnumber(x, T); 
    container.addChild(text.setLocation((-1000), (container.height / 2))); 
    text.moveTo((container.width / 2), (container.height / 2), 500, T); 
}

The idea is to create animation having three numbers that slide form left to center, wait a second and then goes away from the screen. The animation works well, but whena number ends ans start the second moveTo, it firts bounce a bit to the left and the do teh animation. 

Why could happen this?

Is there any way better to do this?

Regards,
Iker

Iker Vázquez

unread,
Jul 8, 2013, 7:33:26 AM7/8/13
to caa...@googlegroups.com
Fixed. It was the setAlign() method.


Reply all
Reply to author
Forward
0 new messages