update
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { _decorator, Component, Node, instantiate } from "cc";
|
||||
import { _decorator, Component, Node, instantiate, tween, Vec3 } from "cc";
|
||||
import li_BaseView from "db://assets/Scripts/Main/Common/li_BaseView";
|
||||
import Utils from "db://assets/Scripts/Main/Common/Utils";
|
||||
import { GButton } from "db://assets/Scripts/Main/Common/GButton";
|
||||
@@ -8,6 +8,7 @@ import { DataManager, DataId } from "../../data/DataManager";
|
||||
import { GirlData } from "../../data/GirlData";
|
||||
import proto from "db://assets/Scripts/proto/proto.pb.js";
|
||||
import { NavigationManager, PanelType } from "../../manager/NavigationManager";
|
||||
import { UITransitionHelper } from "../../utils/UITransitionHelper";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@@ -99,7 +100,8 @@ export class GirlListPanel extends li_BaseView {
|
||||
girlData.setGirlList(category.toString(), res.data);
|
||||
// 根据数据,刷新界面
|
||||
const allId = girlData.getGirlIds(category.toString());
|
||||
for (let id of allId) {
|
||||
for (let i = 0; i < allId.length; i++) {
|
||||
let id = allId[i];
|
||||
let item = this.getItemFromPool();
|
||||
item.refreshData(category, id, this.node);
|
||||
item.node.active = true;
|
||||
@@ -113,6 +115,28 @@ export class GirlListPanel extends li_BaseView {
|
||||
}
|
||||
}
|
||||
|
||||
private addSlideInAnimation(itemNode: Node, index: number) {
|
||||
// 保存节点的目标位置
|
||||
const targetPosition = itemNode.getPosition();
|
||||
|
||||
// 设置初始位置为屏幕右侧外(偏移300像素)
|
||||
const startPosition = new Vec3(
|
||||
targetPosition.x + 300,
|
||||
targetPosition.y,
|
||||
targetPosition.z
|
||||
);
|
||||
itemNode.setPosition(startPosition);
|
||||
|
||||
// 添加递进延时,每个item延迟0.05秒
|
||||
const delay = index * 0.05;
|
||||
|
||||
// 执行滑入动画
|
||||
tween(itemNode)
|
||||
.delay(delay)
|
||||
.to(0.4, { position: targetPosition }, { easing: "cubicOut" })
|
||||
.start();
|
||||
}
|
||||
|
||||
hide() {
|
||||
this.node.active = false;
|
||||
}
|
||||
@@ -121,8 +145,7 @@ export class GirlListPanel extends li_BaseView {
|
||||
GButton.BandClick(this._nodeTab.ReturnBtn, this.Return, this);
|
||||
}
|
||||
Return() {
|
||||
// 直接关闭,不需要动画
|
||||
this.node.active = false;
|
||||
NavigationManager.Instance.closeSubPanel(this);
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
@@ -141,16 +164,5 @@ export class GirlListPanel extends li_BaseView {
|
||||
}
|
||||
}
|
||||
this.cache = [];
|
||||
|
||||
// 清理 content 中所有的 GirlListItem 节点
|
||||
for (let i = this.content.children.length - 1; i >= 0; i--) {
|
||||
let child = this.content.children[i];
|
||||
if (child !== this.itemInst.node) {
|
||||
let item = child.getComponent(GirlListItem);
|
||||
if (item) {
|
||||
child.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user