HandAction.ts 721 B

12345678910111213141516171819202122232425262728
  1. const { ccclass, property } = cc._decorator;
  2. @ccclass
  3. export default class HandAction extends cc.Component {
  4. @property({ type: cc.Float })
  5. runTime: number = 0.3;
  6. onLoad() {
  7. if (cc.winSize.height < cc.winSize.width) {
  8. // 横屏游戏
  9. this.node.scale = cc.view.getDesignResolutionSize().width / 1920 * 0.5;
  10. } else {
  11. this.node.scale = cc.view.getDesignResolutionSize().width / 1080 * 0.5;
  12. }
  13. }
  14. onEnable() {
  15. this.node.runAction(cc.sequence(cc.moveBy(this.runTime, cc.v2(-50, +50)), cc.moveBy(this.runTime, cc.v2(+50, -50))).repeatForever())
  16. }
  17. onDisable() {
  18. this.node.stopAllActions();
  19. }
  20. // update (dt) {}
  21. }