| 12345678910111213141516171819202122232425 |
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class MoveUpAndDown extends cc.Component {
- @property({ displayName: '移动的相对距离' })
- private moveOffset: cc.Vec3 = cc.Vec3.ZERO;
- @property({ displayName: '移动时间' })
- private duration: number = 0;
- private startPos: cc.Vec3 = cc.Vec3.ZERO;
- start() {
- this.node.getPosition(this.startPos);
- let pos = cc.Vec3.ZERO;
- this.startPos.add(this.moveOffset, pos);
- cc.tween(this.node).to(this.duration, { position: pos }).to(this.duration, { position: cc.v3(this.startPos) }, cc.easeSineOut())
- .union().repeatForever().start();
- }
- }
|