|
@@ -1,4 +1,4 @@
|
|
|
-import { _decorator, Component, Node } from 'cc';
|
|
|
+import { _decorator, Component, Node, tween, Vec3 } from 'cc';
|
|
|
const { ccclass, property, executeInEditMode } = _decorator;
|
|
|
|
|
|
@ccclass('OutArea')
|
|
@@ -24,10 +24,9 @@ export class OutArea extends Component {
|
|
|
// 排列杯子
|
|
|
arrangeCups() {
|
|
|
const startX = 40; //水杯的宽度一半
|
|
|
- const spacing = 150;
|
|
|
+ const spacing = 80;
|
|
|
this.cups.forEach((cup, index) => {
|
|
|
cup.setPosition(startX + index * spacing, 0, 0);
|
|
|
- console.log('cup position: ', cup.position);
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -44,6 +43,21 @@ export class OutArea extends Component {
|
|
|
getCups() {
|
|
|
return this.cups;
|
|
|
}
|
|
|
+
|
|
|
+ // 添加带动画排列方法
|
|
|
+ arrangeCupsWithAnimation() {
|
|
|
+ const startX = -200; // 从左侧开始
|
|
|
+ const spacing = 120; // 正间距向右排列
|
|
|
+
|
|
|
+ this.cups.forEach((cup, index) => {
|
|
|
+ const targetPos = new Vec3(startX + index * spacing, 0, 0);
|
|
|
+ if (!cup.position.equals(targetPos)) {
|
|
|
+ tween(cup)
|
|
|
+ .to(0.3, { position: targetPos }, { easing: 'sineOut' })
|
|
|
+ .start();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|