0
我想弄清楚如何对火车动画进行排序,以便我可以在曲线上依次偏移和旋转每个货车,例如,在Route_51(单击测试>运行[两次])中输入this display。需要Chrome或其他符合HTML5的浏览器。铰接式动画
这里是(使用KineticJs)我到目前为止,“不符合要求的”代码:
function animate(nr,path,incr,train,dirX,dirY){
var steps,offsetX,offsetY,count,a;
steps = Math.round(path[nr][2]/incr);
offsetX = path[nr][2]/steps;
offsetY = path[nr][3]/steps;
count = 0;
stage.onFrame(function(frame){
layer = train[0].getLayer();
if(count < steps){
for(a=0; a<train.length; a+=1){
incrX = train[a].getX() + offsetX * -dirX;
incrY = train[a].getY() - offsetY * -dirY;
train[a].setX(incrX);
train[a].setY(incrY);
}
layer.draw();
count += 1;
}
else{
stage.stop();
nr += 1;
if(path[nr]){
animate(nr,path,incr,train,dirX,dirY);
}
}
});
stage.start();
}
我似乎不能够把握逻辑(变老)。
所有帮助表示赞赏。谢谢。