优化转圈
This commit is contained in:
parent
14d9d5b609
commit
e8e06903f4
File diff suppressed because it is too large
Load Diff
|
|
@ -1720,6 +1720,7 @@ export default class JiaZai extends cc.Component {
|
||||||
}
|
}
|
||||||
JiaZai.cachedSharePrefab = prefab;
|
JiaZai.cachedSharePrefab = prefab;
|
||||||
console.log("2222分享预制体已经准备好", shuju);
|
console.log("2222分享预制体已经准备好", shuju);
|
||||||
|
this.closeLoad();
|
||||||
if (!this.ShareNode) {
|
if (!this.ShareNode) {
|
||||||
this.ShareNode = cc.instantiate(JiaZai.cachedSharePrefab);
|
this.ShareNode = cc.instantiate(JiaZai.cachedSharePrefab);
|
||||||
if (this.node && this.ShareNode)
|
if (this.node && this.ShareNode)
|
||||||
|
|
@ -1736,6 +1737,7 @@ export default class JiaZai extends cc.Component {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
this.closeLoad();
|
||||||
if (!this.ShareNode) {
|
if (!this.ShareNode) {
|
||||||
this.ShareNode = cc.instantiate(JiaZai.cachedSharePrefab);
|
this.ShareNode = cc.instantiate(JiaZai.cachedSharePrefab);
|
||||||
if (this.node && this.ShareNode)
|
if (this.node && this.ShareNode)
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,9 @@ export default class Message extends cc.Component {
|
||||||
@property(cc.Prefab)
|
@property(cc.Prefab)
|
||||||
menuLabel: cc.Prefab = null;
|
menuLabel: cc.Prefab = null;
|
||||||
|
|
||||||
|
@property(cc.Prefab)
|
||||||
|
likeComment: cc.Prefab = null;
|
||||||
|
|
||||||
private comment: any[] = [];
|
private comment: any[] = [];
|
||||||
private jushiList: any = null;
|
private jushiList: any = null;
|
||||||
|
|
||||||
|
|
@ -49,24 +52,25 @@ export default class Message extends cc.Component {
|
||||||
private placeholderCount: number = 0;
|
private placeholderCount: number = 0;
|
||||||
|
|
||||||
private _pos: number = 1;
|
private _pos: number = 1;
|
||||||
|
private marqueeScheduler: any = null; // 添加此行来声明变量
|
||||||
|
|
||||||
protected onLoad(): void {
|
protected onLoad(): void {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
|
// 开始调度跑马灯更新
|
||||||
|
this.schedule(this.updateMarquee, 10); // 每10秒执行一次
|
||||||
}
|
}
|
||||||
showNode(nodeType: any, pos: number) {
|
showNode(nodeType: any, pos: number) {
|
||||||
this.node.getChildByName("commentNode").active = false;
|
this.node.getChildByName("commentNode").active = false;
|
||||||
this.node.getChildByName("levelWordNode").active = false;
|
|
||||||
this._pos = pos;
|
this._pos = pos;
|
||||||
console.log("nodeType", nodeType);
|
if (nodeType == "commentNode") {
|
||||||
if (nodeType === "commentNode") {
|
|
||||||
this.node.getChildByName("commentNode").active = true;
|
this.node.getChildByName("commentNode").active = true;
|
||||||
|
console.log("nodeType", nodeType);
|
||||||
this.onShowComment();
|
this.onShowComment();
|
||||||
} else {
|
}
|
||||||
this.node.getChildByName("levelWordNode").active = true;
|
else {
|
||||||
this.onShowLevelWord();
|
this.onShowLevelWord();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -560,228 +564,239 @@ export default class Message extends cc.Component {
|
||||||
this.updateDisplay();
|
this.updateDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
onShowLevelWord() {
|
onGetCommentInfo() {
|
||||||
let levelWordNode = this.node.getChildByName("levelWordNode");
|
// 获取评论信息并启动跑马灯显示
|
||||||
let showNum = 3;
|
|
||||||
|
|
||||||
// 检查是否存在labelContainer节点,如果没有则创建
|
let commentData = [{
|
||||||
let labelContainer = levelWordNode.getChildByName("labelContainer");
|
content: "首先,方块吧",
|
||||||
if (!labelContainer) {
|
head: "https://thirdwx.qlogo.cn/mmopen/vi_32/oCAezhMhThqmsb7ovGhC4ZDU7QoBCYqbLlAJqOofpzkCSOzqmzlXVqVc87ib1Oo9f6HOgbFLSJq83AIefT0M7xTkaE3Jb0kaFKRlYkhJol6M/132",
|
||||||
// 如果场景中没有预设的labelContainer节点,则创建一个新的
|
index: 0,
|
||||||
labelContainer = new cc.Node("labelContainer");
|
like: 2310,
|
||||||
labelContainer.parent = levelWordNode;
|
name: "卡越来越",
|
||||||
labelContainer.zIndex = 100; // 确保label在正确层级
|
uid: "68d0edf0cc79706182bda53f"
|
||||||
|
}, {
|
||||||
|
content: "首先,2*2方块吧",
|
||||||
|
head: "https://thirdwx.qlogo.cn/mmopen/vi_32/oCAezhMhThqmsb7ovGhC4ZDU7QoBCYqbLlAJqOofpzkCSOzqmzlXVqVc87ib1Oo9f6HOgbFLSJq83AIefT0M7xTkaE3Jb0kaFKRlYkhJol6M/132",
|
||||||
|
index: 0,
|
||||||
|
like: 110,
|
||||||
|
name: "卡越来越",
|
||||||
|
uid: "68d0edf0cc79706182bda53f"
|
||||||
|
}, {
|
||||||
|
content: "首先,1x3方块吧",
|
||||||
|
head: "https://thirdwx.qlogo.cn/mmopen/vi_32/oCAezhMhThqmsb7ovGhC4ZDU7QoBCYqbLlAJqOofpzkCSOzqmzlXVqVc87ib1Oo9f6HOgbFLSJq83AIefT0M7xTkaE3Jb0kaFKRlYkhJol6M/132",
|
||||||
|
index: 0,
|
||||||
|
like: 120,
|
||||||
|
name: "卡越来越",
|
||||||
|
uid: "68d0edf0cc79706182bda53f"
|
||||||
|
}, {
|
||||||
|
content: "首先,方块吧",
|
||||||
|
head: "https://thirdwx.qlogo.cn/mmopen/vi_32/oCAezhMhThqmsb7ovGhC4ZDU7QoBCYqbLlAJqOofpzkCSOzqmzlXVqVc87ib1Oo9f6HOgbFLSJq83AIefT0M7xTkaE3Jb0kaFKRlYkhJol6M/132",
|
||||||
|
index: 0,
|
||||||
|
like: 0,
|
||||||
|
name: "卡越来越",
|
||||||
|
uid: "68d0edf0cc79706182bda53f"
|
||||||
|
}, {
|
||||||
|
content: "首先,方块吧",
|
||||||
|
head: "https://thirdwx.qlogo.cn/mmopen/vi_32/oCAezhMhThqmsb7ovGhC4ZDU7QoBCYqbLlAJqOofpzkCSOzqmzlXVqVc87ib1Oo9f6HOgbFLSJq83AIefT0M7xTkaE3Jb0kaFKRlYkhJol6M/132",
|
||||||
|
index: 0,
|
||||||
|
like: 0,
|
||||||
|
name: "卡越来越",
|
||||||
|
uid: "68d0edf0cc79706182bda53f"
|
||||||
|
}];
|
||||||
|
let res = { code: 1, data: commentData, msg: "成功" }
|
||||||
|
|
||||||
|
// Utils.getLikeInfo((res) => {
|
||||||
|
console.log("获取点赞信息", res);
|
||||||
|
|
||||||
|
let comment = res.data;
|
||||||
|
|
||||||
|
const likedDataKey = 'liked_data';
|
||||||
|
let likedData = cc.sys.localStorage.getItem(likedDataKey);
|
||||||
|
likedData = likedData ? JSON.parse(likedData) : { level: null, pos: null, likedIds: [] };
|
||||||
|
|
||||||
|
console.log("从本地获取点赞信息", likedData);
|
||||||
|
// 检查当前关卡等级和pos是否与缓存中的匹配
|
||||||
|
const currentLevel = cc.fx.GameConfig.GM_INFO.level;
|
||||||
|
const currentPos = this._pos;
|
||||||
|
const shouldUseCachedIds = likedData.level === currentLevel && likedData.pos === currentPos;
|
||||||
|
|
||||||
|
// 清除可能存在的旧跑马灯容器
|
||||||
|
const oldContainer = this.node.getChildByName("marqueeContainer");
|
||||||
|
if (oldContainer) {
|
||||||
|
oldContainer.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
let comment = null;
|
// 创建跑马灯容器
|
||||||
// let commentData = [{
|
let marqueeContainer = new cc.Node("marqueeContainer");
|
||||||
// content: "首先,方块吧",
|
marqueeContainer.parent = this.node;
|
||||||
// head: "https://thirdwx.qlogo.cn/mmopen/vi_32/oCAezhMhThqmsb7ovGhC4ZDU7QoBCYqbLlAJqOofpzkCSOzqmzlXVqVc87ib1Oo9f6HOgbFLSJq83AIefT0M7xTkaE3Jb0kaFKRlYkhJol6M/132",
|
// marqueeContainer.setPosition(0, 0); // 初始位置在屏幕右侧外
|
||||||
// index: 0,
|
|
||||||
// like: 2310,
|
|
||||||
// name: "卡越来越",
|
|
||||||
// uid: "68d0edf0cc79706182bda53f"
|
|
||||||
// }, {
|
|
||||||
// content: "首先,2*2方块吧",
|
|
||||||
// head: "https://thirdwx.qlogo.cn/mmopen/vi_32/oCAezhMhThqmsb7ovGhC4ZDU7QoBCYqbLlAJqOofpzkCSOzqmzlXVqVc87ib1Oo9f6HOgbFLSJq83AIefT0M7xTkaE3Jb0kaFKRlYkhJol6M/132",
|
|
||||||
// index: 0,
|
|
||||||
// like: 110,
|
|
||||||
// name: "卡越来越",
|
|
||||||
// uid: "68d0edf0cc79706182bda53f"
|
|
||||||
// }, {
|
|
||||||
// content: "首先,1x3方块吧",
|
|
||||||
// head: "https://thirdwx.qlogo.cn/mmopen/vi_32/oCAezhMhThqmsb7ovGhC4ZDU7QoBCYqbLlAJqOofpzkCSOzqmzlXVqVc87ib1Oo9f6HOgbFLSJq83AIefT0M7xTkaE3Jb0kaFKRlYkhJol6M/132",
|
|
||||||
// index: 0,
|
|
||||||
// like: 120,
|
|
||||||
// name: "卡越来越",
|
|
||||||
// uid: "68d0edf0cc79706182bda53f"
|
|
||||||
// }, {
|
|
||||||
// content: "首先,方块吧",
|
|
||||||
// head: "https://thirdwx.qlogo.cn/mmopen/vi_32/oCAezhMhThqmsb7ovGhC4ZDU7QoBCYqbLlAJqOofpzkCSOzqmzlXVqVc87ib1Oo9f6HOgbFLSJq83AIefT0M7xTkaE3Jb0kaFKRlYkhJol6M/132",
|
|
||||||
// index: 0,
|
|
||||||
// like: 0,
|
|
||||||
// name: "卡越来越",
|
|
||||||
// uid: "68d0edf0cc79706182bda53f"
|
|
||||||
// }, {
|
|
||||||
// content: "首先,方块吧",
|
|
||||||
// head: "https://thirdwx.qlogo.cn/mmopen/vi_32/oCAezhMhThqmsb7ovGhC4ZDU7QoBCYqbLlAJqOofpzkCSOzqmzlXVqVc87ib1Oo9f6HOgbFLSJq83AIefT0M7xTkaE3Jb0kaFKRlYkhJol6M/132",
|
|
||||||
// index: 0,
|
|
||||||
// like: 0,
|
|
||||||
// name: "卡越来越",
|
|
||||||
// uid: "68d0edf0cc79706182bda53f"
|
|
||||||
// }];
|
|
||||||
// let res = { code: 1, data: commentData, msg: "成功" }
|
|
||||||
Utils.getLikeInfo((res) => {
|
|
||||||
console.log("获取点赞信息", res);
|
|
||||||
|
|
||||||
comment = res.data.comment;
|
let showNum = 3;
|
||||||
|
let commentNodes = []; // 存储创建的评论节点数组
|
||||||
|
|
||||||
const likedDataKey = 'liked_data';
|
// 创建指定数量的评论节点
|
||||||
let likedData = cc.sys.localStorage.getItem(likedDataKey);
|
for (let i = 0; i < Math.min(showNum, comment.length); i++) {
|
||||||
likedData = likedData ? JSON.parse(likedData) : { level: null, pos: null, likedIds: [] };
|
// 实例化评论预制体
|
||||||
|
let likeComment = cc.instantiate(this.likeComment);
|
||||||
|
|
||||||
console.log("从本地获取点赞信息", likedData);
|
// 设置节点名称以便管理
|
||||||
// 检查当前关卡等级和pos是否与缓存中的匹配
|
likeComment.name = "likeComment_" + i;
|
||||||
const currentLevel = cc.fx.GameConfig.GM_INFO.level;
|
|
||||||
const currentPos = this._pos;
|
|
||||||
const shouldUseCachedIds = likedData.level === currentLevel && likedData.pos === currentPos;
|
|
||||||
|
|
||||||
// comment = res.data;
|
// 获取子节点
|
||||||
// if (comment.length <= showNum) {
|
let levelNode = likeComment.getChildByName("levelNode");
|
||||||
for (let i = 0; i < comment.length; i++) {
|
let headNode = likeComment.getChildByName("headNode");
|
||||||
let node = levelWordNode.getChildByName("node" + (i + 1));
|
let likeBtn = likeComment.getChildByName("likeBtn");
|
||||||
console.log("node", node)
|
|
||||||
// 检查节点是否存在
|
|
||||||
if (node) {
|
|
||||||
node.active = false;
|
|
||||||
if (i < showNum) {
|
|
||||||
node.active = true;
|
|
||||||
|
|
||||||
// 为每个node添加文本显示,但将Label放在单独的容器中以优化合批
|
if (levelNode && levelNode.getComponent(cc.Label)) {
|
||||||
let labelNode = labelContainer.getChildByName("labelNode" + i);
|
// 设置评论内容到levelNode的label
|
||||||
|
let labelComponent = levelNode.getComponent(cc.Label);
|
||||||
|
labelComponent.string = comment[i].content;
|
||||||
|
|
||||||
// 检查menuLabel是否存在,再实例化
|
// 等待一帧以确保label渲染完成,然后计算宽度
|
||||||
if (!labelNode && this.menuLabel) {
|
this.scheduleOnce(() => {
|
||||||
labelNode = cc.instantiate(this.menuLabel);
|
let labelWidth = labelComponent.node.width;
|
||||||
if (labelNode) {
|
|
||||||
labelNode.name = "labelNode" + i;
|
|
||||||
labelContainer.addChild(labelNode);
|
|
||||||
}
|
|
||||||
} else if (!labelNode && !this.menuLabel) {
|
|
||||||
console.warn(`menuLabel prefab is not assigned, creating label node directly`);
|
|
||||||
// 如果没有预制体,直接创建一个带Label组件的节点
|
|
||||||
labelNode = new cc.Node();
|
|
||||||
let labelComponent = labelNode.addComponent(cc.Label);
|
|
||||||
|
|
||||||
// 设置统一的字体和样式以优化合批
|
// 根据label长度设置headNode和likeBtn的位置
|
||||||
// labelComponent.fontSize = 40;
|
headNode.x = -labelWidth / 2 - 85; // 在label左边-85
|
||||||
// labelComponent.lineHeight = 45;
|
likeBtn.x = labelWidth / 2 + 85; // 在label右边+85
|
||||||
// labelComponent.enableBold = true;
|
}, 0);
|
||||||
labelComponent.horizontalAlign = cc.Label.HorizontalAlign.CENTER;
|
|
||||||
labelComponent.verticalAlign = cc.Label.VerticalAlign.CENTER;
|
|
||||||
labelComponent.overflow = cc.Label.Overflow.NONE;
|
|
||||||
|
|
||||||
// 重要:设置CHAR模式以优化合批
|
|
||||||
labelComponent.cacheMode = cc.Label.CacheMode.CHAR;
|
|
||||||
|
|
||||||
labelNode.name = "labelNode" + i;
|
|
||||||
labelContainer.addChild(labelNode);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检查labelNode是否存在再设置属性
|
|
||||||
if (labelNode) {
|
|
||||||
// 设置label位置与对应的node对齐
|
|
||||||
labelNode.active = true;
|
|
||||||
// 使用node的世界坐标转换为labelContainer的局部坐标
|
|
||||||
labelNode.position = labelContainer.convertToNodeSpaceAR(node.parent.convertToWorldSpaceAR(node.position));
|
|
||||||
|
|
||||||
// 如果需要显示特定文本,可以在这里设置
|
|
||||||
let labelComponent = labelNode.getComponent(cc.Label);
|
|
||||||
if (labelComponent) {
|
|
||||||
// 重要:设置CHAR模式以优化合批
|
|
||||||
labelComponent.cacheMode = cc.Label.CacheMode.CHAR;
|
|
||||||
|
|
||||||
// 设置统一的文本内容,如果需要不同内容,请确保使用相同的字体资源
|
|
||||||
// labelComponent.string = "文本内容";
|
|
||||||
console.log("comment[i].content", comment[i].content);
|
|
||||||
labelComponent.string = comment[i].content;
|
|
||||||
|
|
||||||
// 确保所有Label使用相同的字体和样式设置
|
|
||||||
// labelComponent.font = null; // 清除可能存在的字体资源引用
|
|
||||||
// labelComponent.useSystemFont = true;
|
|
||||||
// labelComponent.fontSize = 60;
|
|
||||||
// labelComponent.lineHeight = 60;
|
|
||||||
// labelComponent.enableBold = true;
|
|
||||||
labelComponent.horizontalAlign = cc.Label.HorizontalAlign.CENTER;
|
|
||||||
labelComponent.verticalAlign = cc.Label.VerticalAlign.CENTER;
|
|
||||||
labelComponent.overflow = cc.Label.Overflow.NONE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取当前节点下的likeBtn
|
|
||||||
let likeBtn = node.getChildByName("likeBtn");
|
|
||||||
if (likeBtn) {
|
|
||||||
// 移除之前的点击事件监听器,避免重复添加
|
|
||||||
likeBtn.off(cc.Node.EventType.TOUCH_END);
|
|
||||||
// 查找或创建点赞数显示标签
|
|
||||||
let likeLabel = node.getChildByName("likeLabel");
|
|
||||||
if (!likeLabel) {
|
|
||||||
// 创建点赞数显示标签
|
|
||||||
likeLabel = new cc.Node("likeLabel");
|
|
||||||
let labelComponent = likeLabel.addComponent(cc.Label);
|
|
||||||
|
|
||||||
// 设置标签样式
|
|
||||||
labelComponent.string = comment[i].like.toString();
|
|
||||||
labelComponent.fontSize = 30;
|
|
||||||
labelComponent.lineHeight = 32;
|
|
||||||
labelComponent.horizontalAlign = cc.Label.HorizontalAlign.LEFT;
|
|
||||||
labelComponent.verticalAlign = cc.Label.VerticalAlign.CENTER;
|
|
||||||
|
|
||||||
// 设置颜色
|
|
||||||
likeLabel.color = cc.Color.BLACK;
|
|
||||||
likeLabel.anchorX = 0;
|
|
||||||
likeLabel.anchorY = 0.5;
|
|
||||||
|
|
||||||
// 添加到节点
|
|
||||||
node.addChild(likeLabel);
|
|
||||||
|
|
||||||
// 设置位置(通常在likeBtn旁边)
|
|
||||||
likeLabel.setPosition(likeBtn.x + likeBtn.width / 2 + 20, likeBtn.y); // 根据实际需求调整位置
|
|
||||||
} else {
|
|
||||||
// 如果标签已存在,更新显示的点赞数
|
|
||||||
let labelComponent = likeLabel.getComponent(cc.Label);
|
|
||||||
if (labelComponent) {
|
|
||||||
labelComponent.string = comment[i].like.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 检查当前评论ID是否已经在本地缓存的已点赞列表中
|
|
||||||
const currentCommentId = comment[i].index; // 使用index作为唯一标识
|
|
||||||
const isAlreadyLiked = shouldUseCachedIds && likedData.likedIds.includes(currentCommentId);
|
|
||||||
|
|
||||||
if (isAlreadyLiked) {
|
|
||||||
// 如果已经点赞过,设置按钮为不可点击状态
|
|
||||||
likeBtn['_hasLiked'] = true;
|
|
||||||
console.log(`节点 ${i + 1} 的likeBtn已点赞过,设置为不可点击状态`);
|
|
||||||
} else {
|
|
||||||
// 如果没有点赞过,添加点击事件
|
|
||||||
likeBtn['_hasLiked'] = false;
|
|
||||||
likeBtn.on(cc.Node.EventType.TOUCH_END, (event) => {
|
|
||||||
if (likeBtn['_hasLiked']) {
|
|
||||||
console.log(`节点 ${i + 1} 的likeBtn已经点赞,不可再次点击`);
|
|
||||||
return; // 如果已经点赞,则不执行后续操作
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(`调用事件信息: 节点 ${i + 1} 的likeBtn被点击,评论内容: ${comment[i].content}, 用户: ${comment[i].name}`);
|
|
||||||
// 这里可以添加点赞逻辑
|
|
||||||
this.handleLikeClick(i, comment[i], likeLabel, likeBtn, currentCommentId, currentLevel, currentPos);
|
|
||||||
}, this);
|
|
||||||
}
|
|
||||||
// 设置按钮的ID,以便在后续处理中识别
|
|
||||||
likeBtn['_commentId'] = currentCommentId;
|
|
||||||
} else {
|
|
||||||
console.warn(`节点 ${i + 1} 下未找到名为 likeBtn 的子节点`);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 如果节点超出显示范围,隐藏其对应的label
|
|
||||||
let labelNode = labelContainer.getChildByName("labelNode" + i);
|
|
||||||
if (labelNode) {
|
|
||||||
labelNode.active = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检查超出范围的节点是否也有likeBtn,也需要处理
|
|
||||||
let likeBtn = node.getChildByName("likeBtn");
|
|
||||||
if (likeBtn) {
|
|
||||||
likeBtn.off(cc.Node.EventType.TOUCH_END); // 移除可能存在的事件监听器
|
|
||||||
likeBtn.active = false; // 隐藏超出范围的点赞按钮
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
console.warn(`Node with name "node${i}" not found in levelWordNode`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
}, this._pos)
|
// 设置点赞相关逻辑
|
||||||
|
const currentCommentId = comment[i].index; // 使用index作为唯一标识
|
||||||
|
const isAlreadyLiked = shouldUseCachedIds && likedData.likedIds.includes(currentCommentId);
|
||||||
|
|
||||||
|
if (likeBtn) {
|
||||||
|
// 移除之前的点击事件监听器,避免重复添加
|
||||||
|
likeBtn.off(cc.Node.EventType.TOUCH_END);
|
||||||
|
|
||||||
|
// 查找或创建点赞数显示标签
|
||||||
|
let likeLabel = likeBtn.getChildByName("likeLabel");
|
||||||
|
if (!likeLabel) {
|
||||||
|
// 创建点赞数显示标签
|
||||||
|
likeLabel = new cc.Node("likeLabel");
|
||||||
|
let labelComponent = likeLabel.addComponent(cc.Label);
|
||||||
|
|
||||||
|
// 设置标签样式
|
||||||
|
labelComponent.string = comment[i].like.toString();
|
||||||
|
labelComponent.fontSize = 40;
|
||||||
|
labelComponent.lineHeight = 42;
|
||||||
|
labelComponent.horizontalAlign = cc.Label.HorizontalAlign.LEFT;
|
||||||
|
labelComponent.verticalAlign = cc.Label.VerticalAlign.CENTER;
|
||||||
|
|
||||||
|
// 设置颜色
|
||||||
|
likeLabel.color = cc.Color.WHITE;
|
||||||
|
|
||||||
|
// 添加到点赞按钮节点
|
||||||
|
likeBtn.addChild(likeLabel);
|
||||||
|
|
||||||
|
// 设置位置(在点赞按钮旁边)
|
||||||
|
likeLabel.setPosition(30, -10); // 根据实际需求调整位置
|
||||||
|
} else {
|
||||||
|
// 如果标签已存在,更新显示的点赞数
|
||||||
|
let labelComponent = likeLabel.getComponent(cc.Label);
|
||||||
|
if (labelComponent) {
|
||||||
|
labelComponent.string = comment[i].like.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isAlreadyLiked) {
|
||||||
|
// 如果已经点赞过,设置按钮为不可点击状态
|
||||||
|
likeBtn['_hasLiked'] = true;
|
||||||
|
console.log(`节点 ${i + 1} 的likeBtn已点赞过,设置为不可点击状态`);
|
||||||
|
} else {
|
||||||
|
// 如果没有点赞过,添加点击事件
|
||||||
|
likeBtn['_hasLiked'] = false;
|
||||||
|
likeBtn.on(cc.Node.EventType.TOUCH_END, (event) => {
|
||||||
|
if (likeBtn['_hasLiked']) {
|
||||||
|
console.log(`节点 ${i + 1} 的likeBtn已经点赞,不可再次点击`);
|
||||||
|
return; // 如果已经点赞,则不执行后续操作
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`调用事件信息: 节点 ${i + 1} 的likeBtn被点击,评论内容: ${comment[i].content}, 用户: ${comment[i].name}`);
|
||||||
|
// 处理点赞逻辑
|
||||||
|
this.handleLikeClick(i, comment[i], likeLabel, likeBtn, currentCommentId, currentLevel, currentPos);
|
||||||
|
}, this);
|
||||||
|
}
|
||||||
|
// 设置按钮的ID,以便在后续处理中识别
|
||||||
|
likeBtn['_commentId'] = currentCommentId;
|
||||||
|
} else {
|
||||||
|
console.warn(`节点 ${i + 1} 下未找到名为 likeBtn 的子节点`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将节点添加到容器中
|
||||||
|
marqueeContainer.addChild(likeComment);
|
||||||
|
|
||||||
|
// 计算每个节点的水平间距
|
||||||
|
likeComment.x = i * 400; // 假设每个节点宽约400,可根据实际情况调整
|
||||||
|
|
||||||
|
// 存储节点引用
|
||||||
|
commentNodes.push(likeComment);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将容器添加到父节点
|
||||||
|
marqueeContainer.parent = this.node;
|
||||||
|
|
||||||
|
// // 开始跑马灯动画
|
||||||
|
// this.startMarqueeAnimation(marqueeContainer, commentNodes);
|
||||||
|
// 保存引用用于后续动画
|
||||||
|
this["marqueeContainer"] = marqueeContainer;
|
||||||
|
this["commentNodes"] = commentNodes;
|
||||||
|
|
||||||
|
// 立即启动一次跑马灯动画
|
||||||
|
this.startSingleMarqueeAnimation();
|
||||||
|
|
||||||
|
// }, this._pos)
|
||||||
|
}
|
||||||
|
|
||||||
|
onShowLevelWord() {
|
||||||
|
// 现在这个方法只负责触发获取评论信息和显示跑马灯
|
||||||
|
this.onGetCommentInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 启动单次跑马灯动画
|
||||||
|
startSingleMarqueeAnimation() {
|
||||||
|
if (!this["marqueeContainer"] || !this["commentNodes"]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const container = this["marqueeContainer"];
|
||||||
|
const nodes = this["commentNodes"];
|
||||||
|
const screenWidth = cc.winSize.width;
|
||||||
|
|
||||||
|
// 设置初始位置,使容器完全在屏幕右侧外
|
||||||
|
container.x = screenWidth;
|
||||||
|
|
||||||
|
// 计算容器总宽度
|
||||||
|
let totalWidth = 0;
|
||||||
|
for (let node of nodes) {
|
||||||
|
totalWidth += node.width + 20; // 加上一些间距
|
||||||
|
}
|
||||||
|
|
||||||
|
// 执行动画:从右向左移动
|
||||||
|
const moveAction = cc.sequence(
|
||||||
|
cc.moveBy(15, -screenWidth - totalWidth, 0), // 根据屏幕宽度和内容总宽度计算移动距离
|
||||||
|
cc.callFunc(() => {
|
||||||
|
// 动画完成后回调,可以重新开始或其他操作
|
||||||
|
console.log("跑马灯动画完成");
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
// 执行动画
|
||||||
|
container.stopAllActions();
|
||||||
|
container.runAction(moveAction);
|
||||||
|
}
|
||||||
|
// 定期更新跑马灯的函数
|
||||||
|
updateMarquee(dt: number) {
|
||||||
|
this.startSingleMarqueeAnimation();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 停止跑马灯动画
|
||||||
|
stopMarqueeAnimation() {
|
||||||
|
if (this.marqueeScheduler) {
|
||||||
|
clearInterval(this.marqueeScheduler);
|
||||||
|
this.marqueeScheduler = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 添加点赞点击处理函数
|
// 添加点赞点击处理函数
|
||||||
|
|
@ -823,45 +838,313 @@ export default class Message extends cc.Component {
|
||||||
}, this._pos, index);
|
}, this._pos, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
onUpLikeClick(event, customData) {
|
|
||||||
console.log("onUpClick", event, customData);
|
|
||||||
|
|
||||||
// 获取当前玩家的名称、头像和当前关卡等级
|
// onShowLevelWord() {
|
||||||
const playerName = cc.fx.GameConfig.GM_INFO.username;
|
|
||||||
const playerAvatar = cc.fx.GameConfig.GM_INFO.useravatar;
|
|
||||||
const currentLevel = cc.fx.GameConfig.GM_INFO.level;
|
|
||||||
|
|
||||||
// 获取留言内容
|
// // 展示评论
|
||||||
const messageContent = this.selectLabel.string; // 使用当前显示的消息内容
|
// let likeComment = cc.instantiate(this.likeComment);
|
||||||
|
// let levelWordNode = this.node.getChildByName("levelWordNode");
|
||||||
|
// let showNum = 3;
|
||||||
|
|
||||||
let likeNum = 0;
|
// // 检查是否存在labelContainer节点,如果没有则创建
|
||||||
|
// let labelContainer = levelWordNode.getChildByName("labelContainer");
|
||||||
|
// if (!labelContainer) {
|
||||||
|
// // 如果场景中没有预设的labelContainer节点,则创建一个新的
|
||||||
|
// labelContainer = new cc.Node("labelContainer");
|
||||||
|
// labelContainer.parent = levelWordNode;
|
||||||
|
// labelContainer.zIndex = 100; // 确保label在正确层级
|
||||||
|
// }
|
||||||
|
|
||||||
let data = {
|
// let comment = null;
|
||||||
name: playerName,
|
// // let commentData = [{
|
||||||
head: playerAvatar,
|
// // content: "首先,方块吧",
|
||||||
content: messageContent,
|
// // head: "https://thirdwx.qlogo.cn/mmopen/vi_32/oCAezhMhThqmsb7ovGhC4ZDU7QoBCYqbLlAJqOofpzkCSOzqmzlXVqVc87ib1Oo9f6HOgbFLSJq83AIefT0M7xTkaE3Jb0kaFKRlYkhJol6M/132",
|
||||||
like: likeNum,
|
// // index: 0,
|
||||||
};
|
// // like: 2310,
|
||||||
let pos = 1;
|
// // name: "卡越来越",
|
||||||
let index = 1;
|
// // uid: "68d0edf0cc79706182bda53f"
|
||||||
// 输出信息到控制台
|
// // }, {
|
||||||
// console.log("玩家名称:", playerName);
|
// // content: "首先,2*2方块吧",
|
||||||
// console.log("玩家头像:", playerAvatar);
|
// // head: "https://thirdwx.qlogo.cn/mmopen/vi_32/oCAezhMhThqmsb7ovGhC4ZDU7QoBCYqbLlAJqOofpzkCSOzqmzlXVqVc87ib1Oo9f6HOgbFLSJq83AIefT0M7xTkaE3Jb0kaFKRlYkhJol6M/132",
|
||||||
// console.log("当前关卡等级:", currentLevel);
|
// // index: 0,
|
||||||
// console.log("留言内容:", messageContent);
|
// // like: 110,
|
||||||
// console.log("lick 0"); // 按照要求添加
|
// // name: "卡越来越",
|
||||||
Utils.setLikeInfo((res) => {
|
// // uid: "68d0edf0cc79706182bda53f"
|
||||||
if (res.code == 1) {
|
// // }, {
|
||||||
// cc.fx.GameTool.shushu_Track("comment", data);
|
// // content: "首先,1x3方块吧",
|
||||||
// cc.fx.GameTool.typingAni(this.selectLabel, messageContent, () => {
|
// // head: "https://thirdwx.qlogo.cn/mmopen/vi_32/oCAezhMhThqmsb7ovGhC4ZDU7QoBCYqbLlAJqOofpzkCSOzqmzlXVqVc87ib1Oo9f6HOgbFLSJq83AIefT0M7xTkaE3Jb0kaFKRlYkhJol6M/132",
|
||||||
// this.onCloseClick(null, null);
|
// // index: 0,
|
||||||
// }, this.node);
|
// // like: 120,
|
||||||
|
// // name: "卡越来越",
|
||||||
|
// // uid: "68d0edf0cc79706182bda53f"
|
||||||
|
// // }, {
|
||||||
|
// // content: "首先,方块吧",
|
||||||
|
// // head: "https://thirdwx.qlogo.cn/mmopen/vi_32/oCAezhMhThqmsb7ovGhC4ZDU7QoBCYqbLlAJqOofpzkCSOzqmzlXVqVc87ib1Oo9f6HOgbFLSJq83AIefT0M7xTkaE3Jb0kaFKRlYkhJol6M/132",
|
||||||
|
// // index: 0,
|
||||||
|
// // like: 0,
|
||||||
|
// // name: "卡越来越",
|
||||||
|
// // uid: "68d0edf0cc79706182bda53f"
|
||||||
|
// // }, {
|
||||||
|
// // content: "首先,方块吧",
|
||||||
|
// // head: "https://thirdwx.qlogo.cn/mmopen/vi_32/oCAezhMhThqmsb7ovGhC4ZDU7QoBCYqbLlAJqOofpzkCSOzqmzlXVqVc87ib1Oo9f6HOgbFLSJq83AIefT0M7xTkaE3Jb0kaFKRlYkhJol6M/132",
|
||||||
|
// // index: 0,
|
||||||
|
// // like: 0,
|
||||||
|
// // name: "卡越来越",
|
||||||
|
// // uid: "68d0edf0cc79706182bda53f"
|
||||||
|
// // }];
|
||||||
|
// // let res = { code: 1, data: commentData, msg: "成功" }
|
||||||
|
// Utils.getLikeInfo((res) => {
|
||||||
|
// console.log("获取点赞信息", res);
|
||||||
|
|
||||||
}
|
// comment = res.data.comment;
|
||||||
}, pos, index)
|
|
||||||
// 删除当前节点
|
// const likedDataKey = 'liked_data';
|
||||||
// this.node.destroy();
|
// let likedData = cc.sys.localStorage.getItem(likedDataKey);
|
||||||
}
|
// likedData = likedData ? JSON.parse(likedData) : { level: null, pos: null, likedIds: [] };
|
||||||
|
|
||||||
|
// console.log("从本地获取点赞信息", likedData);
|
||||||
|
// // 检查当前关卡等级和pos是否与缓存中的匹配
|
||||||
|
// const currentLevel = cc.fx.GameConfig.GM_INFO.level;
|
||||||
|
// const currentPos = this._pos;
|
||||||
|
// const shouldUseCachedIds = likedData.level === currentLevel && likedData.pos === currentPos;
|
||||||
|
|
||||||
|
// // comment = res.data;
|
||||||
|
// // if (comment.length <= showNum) {
|
||||||
|
// for (let i = 0; i < comment.length; i++) {
|
||||||
|
// let node = levelWordNode.getChildByName("node" + (i + 1));
|
||||||
|
// console.log("node", node)
|
||||||
|
// // 检查节点是否存在
|
||||||
|
// if (node) {
|
||||||
|
// node.active = false;
|
||||||
|
// if (i < showNum) {
|
||||||
|
// node.active = true;
|
||||||
|
|
||||||
|
// // 为每个node添加文本显示,但将Label放在单独的容器中以优化合批
|
||||||
|
// let labelNode = labelContainer.getChildByName("labelNode" + i);
|
||||||
|
|
||||||
|
// // 检查menuLabel是否存在,再实例化
|
||||||
|
// if (!labelNode && this.menuLabel) {
|
||||||
|
// labelNode = cc.instantiate(this.menuLabel);
|
||||||
|
// if (labelNode) {
|
||||||
|
// labelNode.name = "labelNode" + i;
|
||||||
|
// labelContainer.addChild(labelNode);
|
||||||
|
// }
|
||||||
|
// } else if (!labelNode && !this.menuLabel) {
|
||||||
|
// console.warn(`menuLabel prefab is not assigned, creating label node directly`);
|
||||||
|
// // 如果没有预制体,直接创建一个带Label组件的节点
|
||||||
|
// labelNode = new cc.Node();
|
||||||
|
// let labelComponent = labelNode.addComponent(cc.Label);
|
||||||
|
|
||||||
|
// // 设置统一的字体和样式以优化合批
|
||||||
|
// // labelComponent.fontSize = 40;
|
||||||
|
// // labelComponent.lineHeight = 45;
|
||||||
|
// // labelComponent.enableBold = true;
|
||||||
|
// labelComponent.horizontalAlign = cc.Label.HorizontalAlign.CENTER;
|
||||||
|
// labelComponent.verticalAlign = cc.Label.VerticalAlign.CENTER;
|
||||||
|
// labelComponent.overflow = cc.Label.Overflow.NONE;
|
||||||
|
|
||||||
|
// // 重要:设置CHAR模式以优化合批
|
||||||
|
// labelComponent.cacheMode = cc.Label.CacheMode.CHAR;
|
||||||
|
|
||||||
|
// labelNode.name = "labelNode" + i;
|
||||||
|
// labelContainer.addChild(labelNode);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // 检查labelNode是否存在再设置属性
|
||||||
|
// if (labelNode) {
|
||||||
|
// // 设置label位置与对应的node对齐
|
||||||
|
// labelNode.active = true;
|
||||||
|
// // 使用node的世界坐标转换为labelContainer的局部坐标
|
||||||
|
// labelNode.position = labelContainer.convertToNodeSpaceAR(node.parent.convertToWorldSpaceAR(node.position));
|
||||||
|
|
||||||
|
// // 如果需要显示特定文本,可以在这里设置
|
||||||
|
// let labelComponent = labelNode.getComponent(cc.Label);
|
||||||
|
// if (labelComponent) {
|
||||||
|
// // 重要:设置CHAR模式以优化合批
|
||||||
|
// labelComponent.cacheMode = cc.Label.CacheMode.CHAR;
|
||||||
|
|
||||||
|
// // 设置统一的文本内容,如果需要不同内容,请确保使用相同的字体资源
|
||||||
|
// // labelComponent.string = "文本内容";
|
||||||
|
// console.log("comment[i].content", comment[i].content);
|
||||||
|
// labelComponent.string = comment[i].content;
|
||||||
|
|
||||||
|
// // 确保所有Label使用相同的字体和样式设置
|
||||||
|
// // labelComponent.font = null; // 清除可能存在的字体资源引用
|
||||||
|
// // labelComponent.useSystemFont = true;
|
||||||
|
// // labelComponent.fontSize = 60;
|
||||||
|
// // labelComponent.lineHeight = 60;
|
||||||
|
// // labelComponent.enableBold = true;
|
||||||
|
// labelComponent.horizontalAlign = cc.Label.HorizontalAlign.CENTER;
|
||||||
|
// labelComponent.verticalAlign = cc.Label.VerticalAlign.CENTER;
|
||||||
|
// labelComponent.overflow = cc.Label.Overflow.NONE;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // 获取当前节点下的likeBtn
|
||||||
|
// let likeBtn = node.getChildByName("likeBtn");
|
||||||
|
// if (likeBtn) {
|
||||||
|
// // 移除之前的点击事件监听器,避免重复添加
|
||||||
|
// likeBtn.off(cc.Node.EventType.TOUCH_END);
|
||||||
|
// // 查找或创建点赞数显示标签
|
||||||
|
// let likeLabel = node.getChildByName("likeLabel");
|
||||||
|
// if (!likeLabel) {
|
||||||
|
// // 创建点赞数显示标签
|
||||||
|
// likeLabel = new cc.Node("likeLabel");
|
||||||
|
// let labelComponent = likeLabel.addComponent(cc.Label);
|
||||||
|
|
||||||
|
// // 设置标签样式
|
||||||
|
// labelComponent.string = comment[i].like.toString();
|
||||||
|
// labelComponent.fontSize = 30;
|
||||||
|
// labelComponent.lineHeight = 32;
|
||||||
|
// labelComponent.horizontalAlign = cc.Label.HorizontalAlign.LEFT;
|
||||||
|
// labelComponent.verticalAlign = cc.Label.VerticalAlign.CENTER;
|
||||||
|
|
||||||
|
// // 设置颜色
|
||||||
|
// likeLabel.color = cc.Color.BLACK;
|
||||||
|
// likeLabel.anchorX = 0;
|
||||||
|
// likeLabel.anchorY = 0.5;
|
||||||
|
|
||||||
|
// // 添加到节点
|
||||||
|
// node.addChild(likeLabel);
|
||||||
|
|
||||||
|
// // 设置位置(通常在likeBtn旁边)
|
||||||
|
// likeLabel.setPosition(likeBtn.x + likeBtn.width / 2 + 20, likeBtn.y); // 根据实际需求调整位置
|
||||||
|
// } else {
|
||||||
|
// // 如果标签已存在,更新显示的点赞数
|
||||||
|
// let labelComponent = likeLabel.getComponent(cc.Label);
|
||||||
|
// if (labelComponent) {
|
||||||
|
// labelComponent.string = comment[i].like.toString();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// // 检查当前评论ID是否已经在本地缓存的已点赞列表中
|
||||||
|
// const currentCommentId = comment[i].index; // 使用index作为唯一标识
|
||||||
|
// const isAlreadyLiked = shouldUseCachedIds && likedData.likedIds.includes(currentCommentId);
|
||||||
|
|
||||||
|
// if (isAlreadyLiked) {
|
||||||
|
// // 如果已经点赞过,设置按钮为不可点击状态
|
||||||
|
// likeBtn['_hasLiked'] = true;
|
||||||
|
// console.log(`节点 ${i + 1} 的likeBtn已点赞过,设置为不可点击状态`);
|
||||||
|
// } else {
|
||||||
|
// // 如果没有点赞过,添加点击事件
|
||||||
|
// likeBtn['_hasLiked'] = false;
|
||||||
|
// likeBtn.on(cc.Node.EventType.TOUCH_END, (event) => {
|
||||||
|
// if (likeBtn['_hasLiked']) {
|
||||||
|
// console.log(`节点 ${i + 1} 的likeBtn已经点赞,不可再次点击`);
|
||||||
|
// return; // 如果已经点赞,则不执行后续操作
|
||||||
|
// }
|
||||||
|
|
||||||
|
// console.log(`调用事件信息: 节点 ${i + 1} 的likeBtn被点击,评论内容: ${comment[i].content}, 用户: ${comment[i].name}`);
|
||||||
|
// // 这里可以添加点赞逻辑
|
||||||
|
// this.handleLikeClick(i, comment[i], likeLabel, likeBtn, currentCommentId, currentLevel, currentPos);
|
||||||
|
// }, this);
|
||||||
|
// }
|
||||||
|
// // 设置按钮的ID,以便在后续处理中识别
|
||||||
|
// likeBtn['_commentId'] = currentCommentId;
|
||||||
|
// } else {
|
||||||
|
// console.warn(`节点 ${i + 1} 下未找到名为 likeBtn 的子节点`);
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// // 如果节点超出显示范围,隐藏其对应的label
|
||||||
|
// let labelNode = labelContainer.getChildByName("labelNode" + i);
|
||||||
|
// if (labelNode) {
|
||||||
|
// labelNode.active = false;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // 检查超出范围的节点是否也有likeBtn,也需要处理
|
||||||
|
// let likeBtn = node.getChildByName("likeBtn");
|
||||||
|
// if (likeBtn) {
|
||||||
|
// likeBtn.off(cc.Node.EventType.TOUCH_END); // 移除可能存在的事件监听器
|
||||||
|
// likeBtn.active = false; // 隐藏超出范围的点赞按钮
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// console.warn(`Node with name "node${i}" not found in levelWordNode`);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// // }
|
||||||
|
|
||||||
|
// }, this._pos)
|
||||||
|
// }
|
||||||
|
|
||||||
|
// 添加点赞点击处理函数
|
||||||
|
|
||||||
|
// private handleLikeClick(index: number, commentData: any, likeLabel: cc.Node, likeBtn: cc.Node, commentId: number, level: number, pos: number) {
|
||||||
|
// console.log(`点赞按钮被点击,索引: ${index}, 评论数据:`, commentData);
|
||||||
|
// Utils.setLikeInfo((res) => {
|
||||||
|
// if (res.code === 1) {
|
||||||
|
// commentData.like += 1;
|
||||||
|
// let labelComponent = likeLabel.getComponent(cc.Label);
|
||||||
|
// if (labelComponent) {
|
||||||
|
// labelComponent.string = commentData.like.toString();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // 设置按钮为已点赞状态,不可再次点击
|
||||||
|
// likeBtn['_hasLiked'] = true;
|
||||||
|
// likeBtn.off(cc.Node.EventType.TOUCH_END); // 移除点击事件
|
||||||
|
|
||||||
|
// // 更新本地缓存中的已点赞数据
|
||||||
|
// const likedDataKey = 'liked_data';
|
||||||
|
// let likedData = cc.sys.localStorage.getItem(likedDataKey);
|
||||||
|
// likedData = likedData ? JSON.parse(likedData) : { level: null, pos: null, likedIds: [] };
|
||||||
|
|
||||||
|
// // 更新关卡等级和pos
|
||||||
|
// likedData.level = level;
|
||||||
|
// likedData.pos = pos;
|
||||||
|
|
||||||
|
// // 添加当前ID到已点赞列表(如果不存在)
|
||||||
|
// if (!likedData.likedIds.includes(commentId)) {
|
||||||
|
// likedData.likedIds.push(commentId);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // 保存到本地缓存
|
||||||
|
// cc.sys.localStorage.setItem(likedDataKey, JSON.stringify(likedData));
|
||||||
|
|
||||||
|
// console.log("点赞成功!");
|
||||||
|
// } else {
|
||||||
|
// console.log("点赞失败!");
|
||||||
|
// }
|
||||||
|
// }, this._pos, index);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// onUpLikeClick(event, customData) {
|
||||||
|
// console.log("onUpClick", event, customData);
|
||||||
|
|
||||||
|
// // 获取当前玩家的名称、头像和当前关卡等级
|
||||||
|
// const playerName = cc.fx.GameConfig.GM_INFO.username;
|
||||||
|
// const playerAvatar = cc.fx.GameConfig.GM_INFO.useravatar;
|
||||||
|
// const currentLevel = cc.fx.GameConfig.GM_INFO.level;
|
||||||
|
|
||||||
|
// // 获取留言内容
|
||||||
|
// const messageContent = this.selectLabel.string; // 使用当前显示的消息内容
|
||||||
|
|
||||||
|
// let likeNum = 0;
|
||||||
|
|
||||||
|
// let data = {
|
||||||
|
// name: playerName,
|
||||||
|
// head: playerAvatar,
|
||||||
|
// content: messageContent,
|
||||||
|
// like: likeNum,
|
||||||
|
// };
|
||||||
|
// let pos = 1;
|
||||||
|
// let index = 1;
|
||||||
|
// // 输出信息到控制台
|
||||||
|
// // console.log("玩家名称:", playerName);
|
||||||
|
// // console.log("玩家头像:", playerAvatar);
|
||||||
|
// // console.log("当前关卡等级:", currentLevel);
|
||||||
|
// // console.log("留言内容:", messageContent);
|
||||||
|
// // console.log("lick 0"); // 按照要求添加
|
||||||
|
// Utils.setLikeInfo((res) => {
|
||||||
|
// if (res.code == 1) {
|
||||||
|
// // cc.fx.GameTool.shushu_Track("comment", data);
|
||||||
|
// // cc.fx.GameTool.typingAni(this.selectLabel, messageContent, () => {
|
||||||
|
// // this.onCloseClick(null, null);
|
||||||
|
// // }, this.node);
|
||||||
|
|
||||||
|
// }
|
||||||
|
// }, pos, index)
|
||||||
|
// // 删除当前节点
|
||||||
|
// // this.node.destroy();
|
||||||
|
// }
|
||||||
// 清除所有
|
// 清除所有
|
||||||
clearAll() {
|
clearAll() {
|
||||||
this.columnValues.clear();
|
this.columnValues.clear();
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ export default class SceneManager extends cc.Component {
|
||||||
avatar: cc.SpriteAtlas = null;
|
avatar: cc.SpriteAtlas = null;
|
||||||
|
|
||||||
@property(cc.Prefab)
|
@property(cc.Prefab)
|
||||||
messageNode: cc.Node = null;
|
messageNode: cc.Prefab = null;
|
||||||
|
|
||||||
|
|
||||||
particleEffects: cc.ParticleAsset[];
|
particleEffects: cc.ParticleAsset[];
|
||||||
|
|
@ -672,16 +672,27 @@ export default class SceneManager extends cc.Component {
|
||||||
let reddemCodeNode = cc.instantiate(this.messageNode);
|
let reddemCodeNode = cc.instantiate(this.messageNode);
|
||||||
let messageScrpit = reddemCodeNode.getComponent("Message");
|
let messageScrpit = reddemCodeNode.getComponent("Message");
|
||||||
let nodeType = "commentNode";
|
let nodeType = "commentNode";
|
||||||
console.log("打开界面", nodeType);
|
console.log("打开留言界面", nodeType);
|
||||||
let pos = 1;
|
let pos = 1;
|
||||||
messageScrpit.showNode(nodeType, pos);
|
messageScrpit.showNode(nodeType, pos);
|
||||||
this.node.addChild(reddemCodeNode);
|
this.node.addChild(reddemCodeNode);
|
||||||
}
|
}
|
||||||
openMessage2() {
|
openMessage2() {
|
||||||
|
// 检查 messageNode 是否已经分配了预制体
|
||||||
|
if (!this.messageNode) {
|
||||||
|
cc.error("messageNode 预制体未分配,请在编辑器中设置");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let reddemCodeNode = cc.instantiate(this.messageNode);
|
let reddemCodeNode = cc.instantiate(this.messageNode);
|
||||||
let messageScrpit = reddemCodeNode.getComponent("Message");
|
let messageScrpit = reddemCodeNode.getComponent("Message");
|
||||||
let nodeType = "levelWordNode";
|
if (!messageScrpit) {
|
||||||
console.log("打开界面", nodeType);
|
cc.error("Message 组件未找到,请确保预制体中包含 Message 组件");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let nodeType = "likeComment";
|
||||||
|
console.log("打开点赞界面", nodeType);
|
||||||
let pos = 1;
|
let pos = 1;
|
||||||
messageScrpit.showNode(nodeType, pos);
|
messageScrpit.showNode(nodeType, pos);
|
||||||
this.node.addChild(reddemCodeNode);
|
this.node.addChild(reddemCodeNode);
|
||||||
|
|
|
||||||
|
|
@ -507,10 +507,15 @@ export default class Utils {
|
||||||
if (cc.fx.GameConfig.GM_INFO.level <= 0 || cc.fx.GameConfig.GM_INFO.level == undefined) {
|
if (cc.fx.GameConfig.GM_INFO.level <= 0 || cc.fx.GameConfig.GM_INFO.level == undefined) {
|
||||||
cc.fx.GameConfig.GM_INFO.level = 0;
|
cc.fx.GameConfig.GM_INFO.level = 0;
|
||||||
}
|
}
|
||||||
|
let wuXian = false;
|
||||||
|
if (cc.fx.GameTool.maxLevel() && cc.fx.GameConfig.GM_INFO.GameplayType == 1) {
|
||||||
|
wuXian = true;
|
||||||
|
}
|
||||||
let setData = {
|
let setData = {
|
||||||
uid: cc.fx.GameConfig.GM_INFO.uid,
|
uid: cc.fx.GameConfig.GM_INFO.uid,
|
||||||
action: 'save',
|
action: 'save',
|
||||||
levelAmount: parseInt(cc.fx.GameConfig.GM_INFO.level)
|
levelAmount: parseInt(cc.fx.GameConfig.GM_INFO.level),
|
||||||
|
isWuXian: wuXian
|
||||||
}
|
}
|
||||||
Utils.POST("userLevel", setData, res => {
|
Utils.POST("userLevel", setData, res => {
|
||||||
//console.log("获得userLevel数据:", res);
|
//console.log("获得userLevel数据:", res);
|
||||||
|
|
|
||||||
BIN
assets/UI/UI/comment_btn.png
Normal file
BIN
assets/UI/UI/comment_btn.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
38
assets/UI/UI/comment_btn.png.meta
Normal file
38
assets/UI/UI/comment_btn.png.meta
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
{
|
||||||
|
"ver": "2.3.7",
|
||||||
|
"uuid": "9212a9ef-1256-47c0-8ab6-5fdf3ddba77d",
|
||||||
|
"importer": "texture",
|
||||||
|
"type": "sprite",
|
||||||
|
"wrapMode": "clamp",
|
||||||
|
"filterMode": "bilinear",
|
||||||
|
"premultiplyAlpha": false,
|
||||||
|
"genMipmaps": false,
|
||||||
|
"packable": true,
|
||||||
|
"width": 175,
|
||||||
|
"height": 190,
|
||||||
|
"platformSettings": {},
|
||||||
|
"subMetas": {
|
||||||
|
"comment_btn": {
|
||||||
|
"ver": "1.0.6",
|
||||||
|
"uuid": "1031d763-fae8-4612-9444-2d3aaa1cb813",
|
||||||
|
"importer": "sprite-frame",
|
||||||
|
"rawTextureUuid": "9212a9ef-1256-47c0-8ab6-5fdf3ddba77d",
|
||||||
|
"trimType": "auto",
|
||||||
|
"trimThreshold": 1,
|
||||||
|
"rotated": false,
|
||||||
|
"offsetX": 0,
|
||||||
|
"offsetY": 0,
|
||||||
|
"trimX": 0,
|
||||||
|
"trimY": 0,
|
||||||
|
"width": 175,
|
||||||
|
"height": 190,
|
||||||
|
"rawWidth": 175,
|
||||||
|
"rawHeight": 190,
|
||||||
|
"borderTop": 0,
|
||||||
|
"borderBottom": 0,
|
||||||
|
"borderLeft": 0,
|
||||||
|
"borderRight": 0,
|
||||||
|
"subMetas": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
assets/UI/UI/comment_like_btn.png
Normal file
BIN
assets/UI/UI/comment_like_btn.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
38
assets/UI/UI/comment_like_btn.png.meta
Normal file
38
assets/UI/UI/comment_like_btn.png.meta
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
{
|
||||||
|
"ver": "2.3.7",
|
||||||
|
"uuid": "5a6dbc7f-e21b-4f98-badf-cd1bbf6c3777",
|
||||||
|
"importer": "texture",
|
||||||
|
"type": "sprite",
|
||||||
|
"wrapMode": "clamp",
|
||||||
|
"filterMode": "bilinear",
|
||||||
|
"premultiplyAlpha": false,
|
||||||
|
"genMipmaps": false,
|
||||||
|
"packable": true,
|
||||||
|
"width": 68,
|
||||||
|
"height": 68,
|
||||||
|
"platformSettings": {},
|
||||||
|
"subMetas": {
|
||||||
|
"comment_like_btn": {
|
||||||
|
"ver": "1.0.6",
|
||||||
|
"uuid": "ff4bcb85-1f40-44e2-9be2-60f766db6413",
|
||||||
|
"importer": "sprite-frame",
|
||||||
|
"rawTextureUuid": "5a6dbc7f-e21b-4f98-badf-cd1bbf6c3777",
|
||||||
|
"trimType": "auto",
|
||||||
|
"trimThreshold": 1,
|
||||||
|
"rotated": false,
|
||||||
|
"offsetX": 0,
|
||||||
|
"offsetY": 0,
|
||||||
|
"trimX": 0,
|
||||||
|
"trimY": 0,
|
||||||
|
"width": 68,
|
||||||
|
"height": 68,
|
||||||
|
"rawWidth": 68,
|
||||||
|
"rawHeight": 68,
|
||||||
|
"borderTop": 0,
|
||||||
|
"borderBottom": 0,
|
||||||
|
"borderLeft": 0,
|
||||||
|
"borderRight": 0,
|
||||||
|
"subMetas": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
1107
assets/prefab/map/likeComment.prefab
Normal file
1107
assets/prefab/map/likeComment.prefab
Normal file
File diff suppressed because it is too large
Load Diff
9
assets/prefab/map/likeComment.prefab.meta
Normal file
9
assets/prefab/map/likeComment.prefab.meta
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"ver": "1.3.2",
|
||||||
|
"uuid": "7c85f3b0-5813-43a3-a2c0-7b2bd7f83e43",
|
||||||
|
"importer": "prefab",
|
||||||
|
"optimizationPolicy": "AUTO",
|
||||||
|
"asyncLoadAssets": false,
|
||||||
|
"readonly": false,
|
||||||
|
"subMetas": {}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user