Quantcast
Channel: Cocos中文社区 - 最新主题
Viewing all articles
Browse latest Browse all 88851

creator 使用TS实现聊天窗口的显示,如何使用队列来实现先进先出的效果

$
0
0

@949252127 写道:

下面时聊天窗口的内容,包括表情和文字
import { ComUI } from "../../../../utils/ComUI";

const { ccclass, property } = cc._decorator;

@ccclass
export default class ChatDialog extends cc.Component {
@property(cc.SpriteFrame)
emoj1: cc.SpriteFrame = null;
@property(cc.SpriteFrame)
emoj2:cc.SpriteFrame = null;
@property(cc.SpriteFrame)
emoj3:cc.SpriteFrame = null;
@property(cc.SpriteFrame)
emoj4:cc.SpriteFrame = null;
@property(cc.SpriteFrame)
emoj5:cc.SpriteFrame = null;
@property(cc.SpriteFrame)
emoj6:cc.SpriteFrame = null;
@property(cc.SpriteFrame)
emoj7:cc.SpriteFrame = null;
@property(cc.SpriteFrame)
emoj8:cc.SpriteFrame = null;

@property(cc.Node)
emojNode: cc.Node = null;

@property(cc.EditBox)
chatLable: cc.EditBox = null;
public onSendClick(): void {
    let EditBoxString = this.chatLable.string;
    if (EditBoxString.length > 0) {
        ComUI.showChatMessage(EditBoxString, 1.5)
        this.node.destroy();
    } else {
        ComUI.showToast("请输入文字", 1.5);
    }
}
//文字按钮
public onTextClick(event, CustomEventData): void {
    console.log('custom date=' + CustomEventData);
    if (CustomEventData === '1') {
        ComUI.showChatMessage("大家多多关照", 1.5)
    } else if (CustomEventData === '2') {
        ComUI.showChatMessage("看到没,赌神就在这里", 1.5)
    } else if (CustomEventData === '3') {
        ComUI.showChatMessage("赶紧出牌啊!", 1.5)
    } else if (CustomEventData === '4') {
        ComUI.showChatMessage("风水轮流转", 1.5)
    } else if (CustomEventData === '5') {
        ComUI.showChatMessage("怎么会这样呢?", 1.5)
    } else if (CustomEventData === '6') {
        ComUI.showChatMessage("手气怎么这么衰啊!", 1.5)
    } else if (CustomEventData === '0') {
        this.node.destroy();
    }
    this.node.destroy();
}

//表情按钮
public onEmojCliack(event,CustomEventData): void {
    console.log('custom emoj=' + CustomEventData);
    if(CustomEventData ==='01'){
        ComUI.showEmojSprite(this.emoj1)
    }else if(CustomEventData === '02'){
        ComUI.showEmojSprite(this.emoj2)
    }else if(CustomEventData === '03'){
        ComUI.showEmojSprite(this.emoj3)
    }else if(CustomEventData === '04'){
        ComUI.showEmojSprite(this.emoj4)
    }else if(CustomEventData === '05'){
        ComUI.showEmojSprite(this.emoj5)
    }else if(CustomEventData === '06'){
        ComUI.showEmojSprite(this.emoj6)
    }else if(CustomEventData === '07'){
        ComUI.showEmojSprite(this.emoj7)
    }else if(CustomEventData === '08'){
        ComUI.showEmojSprite(this.emoj8)
    }
   this.node.destroy();
}

}
目前实现效果可以显示聊天窗口,但在上一个没有消失时,下一个会重叠。表情也是如此。

帖子: 1

参与者: 1

阅读整个主题


Viewing all articles
Browse latest Browse all 88851

Trending Articles