script.js 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. CMD:
  2. console.log("====>>>>远程脚本加载成功");
  3. //var cScene = cc.director.getScene();
  4. //let scene = cc.director.getScene();
  5. //let layersCount = scene.childrenCount;
  6. //console.log("图层数量:", layersCount);
  7. //
  8. //function getTotalComponentsCount(node) {
  9. // let count = node.getComponents(cc.Component).length;
  10. // node.children.forEach(childNode => {
  11. // count += getTotalComponentsCount(childNode);
  12. // });
  13. // return count;
  14. //}
  15. //
  16. //// 使用当前场景的根节点作为起点
  17. //let totalComponents = getTotalComponentsCount(scene);
  18. //console.log("场景中的组件总数量:", totalComponents);
  19. //function printNodePath(node, path = '') {
  20. // // 构建当前节点的路径
  21. // let currentPath = path ? `${path}/${node.name}` : node.name;
  22. // console.log(currentPath); // 打印当前节点的路径
  23. // lws.send(currentPath);
  24. // // 遍历子节点
  25. // node.children.forEach((child) => {
  26. // printNodePath(child, currentPath);
  27. // });
  28. //}
  29. //
  30. // 获取当前场景的根节点并开始遍历
  31. //let scene = cc.director.getScene();
  32. //scene.children.forEach((child) => {
  33. // // 假设每个直接子节点都是一个“图层”
  34. // printNodePath(child);
  35. //});
  36. //
  37. //function printNodePath(node, path = '') {
  38. // // 构建当前节点的路径
  39. // let currentPath = path ? `${path}/${node.name}` : node.name;
  40. //
  41. // // 检查节点是否有 cc.Button 组件,这意味着它监听了点击事件
  42. // let buttonComponent = node.getComponent(cc.Button);
  43. //
  44. // // 可以根据需要,检查其他组件,如 cc.ScrollView 等
  45. //
  46. // if (buttonComponent) {
  47. // console.log(currentPath); // 打印当前节点的路径
  48. // lws.send(currentPath);
  49. // }
  50. //
  51. // // 遍历子节点
  52. // node.children.forEach((child) => {
  53. // printNodePath(child, currentPath);
  54. // });
  55. //}
  56. //// 获取当前场景的根节点并开始遍历
  57. //let scene = cc.director.getScene();
  58. //scene.children.forEach((child) => {
  59. // printNodePath(child);
  60. //});
  61. // 点击扑克大师游戏
  62. let pokerMasterGame = cc.find("Canvas/container/content/smallGame/createScrollView/view/cotent/row1/pokerNode/porkermaster/allHand");//进入大师线路列表
  63. //let pokerMasterGame = cc.find("Canvas/container/content/smallGame/New Node/listPokerMasterContent/btn_down");//大师线路列表按钮下降
  64. // 检查节点是否找到以及是否有cc.Button组件
  65. if (pokerMasterGame && pokerMasterGame.getComponent(cc.Button)) {
  66. // 模拟点击事件
  67. pokerMasterGame.getComponent(cc.Button).clickEvents[0].emit([pokerMasterGame]);
  68. } else {
  69. // console.error("节点未找到或节点上没有cc.Button组件");
  70. console.error("未找到扑克大师游戏");
  71. }
  72. // 点击扑克大师游戏线路1
  73. let pokerMasterGameLine1 = cc.find("Canvas/container/content/smallGame/New Node/listPokerMasterContent/main/view/content/item/main");//线路1
  74. if (pokerMasterGameLine1 && pokerMasterGameLine1.getComponent(cc.Button)) {
  75. // 模拟点击事件
  76. pokerMasterGameLine1.getComponent(cc.Button).clickEvents[0].emit([pokerMasterGameLine1]);
  77. } else {
  78. // console.error("节点未找到或节点上没有cc.Button组件");
  79. console.error("未找到扑克大师游戏游戏节点1");
  80. }
  81. //lws.send("存到本地");
  82. console.log("====>>>>远程脚本加载结束");