update
This commit is contained in:
@@ -30,7 +30,7 @@ export class ChatContentsLayout extends Component {
|
||||
// 缓存池
|
||||
private cachedBubbles: DialogBubble[] = [];
|
||||
// 等待回复气泡的引用
|
||||
private waitingBubble: DialogBubble = null;
|
||||
//private waitingBubble: DialogBubble = null;
|
||||
// 延时任务ID数组
|
||||
private delayedTasks: number[] = [];
|
||||
// ScrollView组件引用
|
||||
@@ -52,13 +52,22 @@ export class ChatContentsLayout extends Component {
|
||||
this.fixMaxWidth = 730;
|
||||
|
||||
// 获取或添加UIOpacity组件到content节点
|
||||
this.contentOpacity = this.node.getComponent(UIOpacity) || this.node.addComponent(UIOpacity);
|
||||
this.contentOpacity =
|
||||
this.node.getComponent(UIOpacity) || this.node.addComponent(UIOpacity);
|
||||
|
||||
// 注册触摸事件
|
||||
if (this.scrollView && this.scrollView.node) {
|
||||
this.scrollView.node.on(NodeEventType.TOUCH_START, this.onTouchStart, this);
|
||||
this.scrollView.node.on(
|
||||
NodeEventType.TOUCH_START,
|
||||
this.onTouchStart,
|
||||
this
|
||||
);
|
||||
this.scrollView.node.on(NodeEventType.TOUCH_END, this.onTouchEnd, this);
|
||||
this.scrollView.node.on(NodeEventType.TOUCH_CANCEL, this.onTouchEnd, this);
|
||||
this.scrollView.node.on(
|
||||
NodeEventType.TOUCH_CANCEL,
|
||||
this.onTouchEnd,
|
||||
this
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,11 +94,11 @@ export class ChatContentsLayout extends Component {
|
||||
this.bubbles.push(playerBubble);
|
||||
|
||||
// 创建等待回复气泡(插入到首位,显示在玩家消息上面)
|
||||
this.waitingBubble = this.createOrGetBubble(false);
|
||||
this.waitingBubble.node.active = true;
|
||||
this.waitingBubble.updateBubbleContent("...", false, undefined, true);
|
||||
this.waitingBubble.node.setSiblingIndex(0);
|
||||
this.bubbles.push(this.waitingBubble);
|
||||
// this.waitingBubble = this.createOrGetBubble(false);
|
||||
// this.waitingBubble.node.active = true;
|
||||
// this.waitingBubble.updateBubbleContent("...", false, undefined, true);
|
||||
// this.waitingBubble.node.setSiblingIndex(0);
|
||||
// this.bubbles.push(this.waitingBubble);
|
||||
this.node.position = Vec3.ZERO;
|
||||
// 滚动到底部(等待下一帧Layout更新完成)
|
||||
this.scheduleOnce(() => {
|
||||
@@ -102,9 +111,9 @@ export class ChatContentsLayout extends Component {
|
||||
*/
|
||||
updateAIDialogs(dialogs: Dialog[]): void {
|
||||
// 清除等待回复气泡
|
||||
if (this.waitingBubble) {
|
||||
this.removeWaitingBubble();
|
||||
}
|
||||
// if (this.waitingBubble) {
|
||||
// this.removeWaitingBubble();
|
||||
// }
|
||||
|
||||
// 清理之前的延时任务
|
||||
this.clearDelayedTasks();
|
||||
@@ -124,7 +133,7 @@ export class ChatContentsLayout extends Component {
|
||||
}
|
||||
}
|
||||
this.bubbles = [];
|
||||
this.waitingBubble = null;
|
||||
//this.waitingBubble = null;
|
||||
|
||||
// 清理多余的缓存气泡
|
||||
this.cleanupExcessCachedBubbles();
|
||||
@@ -164,19 +173,19 @@ export class ChatContentsLayout extends Component {
|
||||
/**
|
||||
* 移除等待回复气泡
|
||||
*/
|
||||
private removeWaitingBubble(): void {
|
||||
if (this.waitingBubble && this.waitingBubble.node) {
|
||||
this.waitingBubble.node.active = false;
|
||||
this.cachedBubbles.push(this.waitingBubble);
|
||||
// private removeWaitingBubble(): void {
|
||||
// if (this.waitingBubble && this.waitingBubble.node) {
|
||||
// this.waitingBubble.node.active = false;
|
||||
// this.cachedBubbles.push(this.waitingBubble);
|
||||
|
||||
// 从当前气泡列表中移除
|
||||
const index = this.bubbles.indexOf(this.waitingBubble);
|
||||
if (index > -1) {
|
||||
this.bubbles.splice(index, 1);
|
||||
}
|
||||
}
|
||||
this.waitingBubble = null;
|
||||
}
|
||||
// // 从当前气泡列表中移除
|
||||
// const index = this.bubbles.indexOf(this.waitingBubble);
|
||||
// if (index > -1) {
|
||||
// this.bubbles.splice(index, 1);
|
||||
// }
|
||||
// }
|
||||
// this.waitingBubble = null;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 带延时地添加AI对话
|
||||
@@ -316,9 +325,17 @@ export class ChatContentsLayout extends Component {
|
||||
protected onDestroy(): void {
|
||||
// 清理事件监听
|
||||
if (this.scrollView && this.scrollView.node) {
|
||||
this.scrollView.node.off(NodeEventType.TOUCH_START, this.onTouchStart, this);
|
||||
this.scrollView.node.off(
|
||||
NodeEventType.TOUCH_START,
|
||||
this.onTouchStart,
|
||||
this
|
||||
);
|
||||
this.scrollView.node.off(NodeEventType.TOUCH_END, this.onTouchEnd, this);
|
||||
this.scrollView.node.off(NodeEventType.TOUCH_CANCEL, this.onTouchEnd, this);
|
||||
this.scrollView.node.off(
|
||||
NodeEventType.TOUCH_CANCEL,
|
||||
this.onTouchEnd,
|
||||
this
|
||||
);
|
||||
}
|
||||
|
||||
// 清理计时器
|
||||
|
||||
Reference in New Issue
Block a user