const { ccclass, property } = cc._decorator; /** * 世界公告 滚动播放 * @author 邹勇 */ @ccclass export default class TweenCast extends cc.Component { @property({ type: cc.RichText, displayName: "公告内容" }) private rich_text: cc.RichText = null; @property({ displayName: "显示时间" }) private display_time: number = 5; @property({ displayName: "进出速度" }) private move_speed: number = 3; @property({ displayName: "等待时间" }) private wait_time: number = 10; private names: string[] = ["拒绝寂寞", "孽緣", "祗為与妳相爱", "羙男", "浅蓝", "腊笔小东", "卡布奇诺", "苊狠幸福", "埋葬回忆", "早已该放手", "白兎", "豿疍疍", "宿命", "渗透的葬礼", "全都是虚假", "俄侑伱-直", "隱裑", "你不配我", "非主流网名", "剧终", "如果沵走了", "續雪", "默默然", "大白痴", "衮开", "越长大越不安", "寶疍疍", "爱笑的眼睛", "暧昧", "午夜", "我继续坚强", "冷温柔", "蹲在脚落", "喲妞你赞", "满足沵", "泪流", "听风在唱歌", "假装", "海岸线丶", "流年换ノ", "细数惭愧", "寂寞别说爱╮", "疯男人", "Darling", "伤狠痛", "留的住我不要", "静静的思念", "涐愿化作飞蛾", "欲", "提苏米拉", "夜凄凉", "一种矜持", "哼,涐呸", "贪婪", "一败涂地", "美如此多娇", "暧昧已落幕", "地平线"]; private moneys: number[] = [0.5, 0.8, 1.0, 2, 5, 10, 20, 100]; private weights: number[] = [40, 20, 10, 10, 10, 5, 3, 2]; /** * 随机生成一个世界公告 */ private getContent(): string { let len = this.names.length; let i = Math.floor(mk.math.random(0, len, false)); let name = this.names[i]; len = this.moneys.length; i = mk.math.randomByWeight(this.weights, 100, false); let money = this.moneys[i]; return `${name}成功提现了${money}元`; } onLoad() { if (gData.gameData.funOpenData['6'] == '1') { this.node.active = true this.play(); } else { this.node.active = false } } private play() { this.reset(); cc.tween(this.node) .delay(this.wait_time) .call(this.rickPlay.bind(this)).start(); } private rickPlay() { this.node.active = true; cc.tween(this.rich_text.node) .to(this.move_speed, { x: 16 }) .delay(this.display_time) .to(this.move_speed, { x: -450 }) .call(this.play.bind(this)).start(); } private reset() { this.node.active = false; this.rich_text.node.x = 450; this.rich_text.string = this.getContent(); } }