在 EDC 脚本中将过渡从线性更改为减速

Change transition from linear to decelerate in EDC script

在EDC中,我可以在collections/group中使用scripts来制作动画:

group { "my_group";
  script {
     public my_anim(val, Float:pos) {
        set_tween_state(PART:"elm.text", pos, "state_begin", 0.0, "state_end", 0.0);
     }
     public start_my_anim() {
        anim(1 /*duration in seconds*/, "my_anim", 1 /*I have no idea about this param*/);
     }
  }

  parts {
     text { "elm.text";
        desc { "state_begin";
           ...           
        }            
        desc { "state_end";
           ...
        }            
     }    
  }
}

如果我调用 start_my_anim,它会为我的文字添加动画效果,太棒了!

但它会以 LINEAR 过渡动画。我怎样才能让 anim 使用 DECELERATE?

您可以使用 set_tween_state_anim() 代替 set_tween_state(),如下所示。

set_tween_state_anim(PART:"elm.text", "state_begin", 0.0, "state_end", 0.0, DECELERATE, pos);
//There are some transition modes. (e.g. LINEAR, ACCELERATE, DECELERATE, etc.)

顺便说一句,anim() 的最后一个参数作为脚本函数的值参数传递。

public my_anim(val, Float:pos) {
    if (val == 9) { // This is the last parameter of anim function.
        set_tween_state(PART:"elm.text", pos, "state_begin", 0.0, "state_end", 0.0);
    }
}
public start_my_anim() {
    anim(1, "my_anim", 9); // The last parameter is passed as the value parameter of the script function.
}

谢谢。