TweenCast.ts 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. const { ccclass, property } = cc._decorator;
  2. /**
  3. * 世界公告 滚动播放
  4. * @author 邹勇
  5. */
  6. @ccclass
  7. export default class TweenCast extends cc.Component {
  8. @property({ type: cc.RichText, displayName: "公告内容" })
  9. private rich_text: cc.RichText = null;
  10. @property({ displayName: "显示时间" })
  11. private display_time: number = 5;
  12. @property({ displayName: "进出速度" })
  13. private move_speed: number = 2;
  14. @property({ displayName: "等待时间" })
  15. private wait_time: number = 10;
  16. onLoad() {
  17. this.reset();
  18. }
  19. start() {
  20. cc.tween(this.node)
  21. .delay(3)
  22. .call(() => {
  23. this.node.active = true;
  24. }, this)
  25. .to(3, { x: 100 })
  26. .delay(5)
  27. .to(3, { x: -100 })
  28. .call(this.reset.bind(this))
  29. .union().repeatForever().start();
  30. }
  31. private reset() {
  32. this.node.active = false;
  33. this.rich_text.node.x = 250;
  34. }
  35. }