Commit e0b029c3 authored by sunboylu's avatar sunboylu

feat testzg001

parent c71b356e
No preview for this file type
# Cocos Creator 项目架构文档
## 项目概述
这是一个基于 Cocos Creator 2.4.5 的游戏开发项目,集成了多种开发工具和组件,包括表单编辑器、Angular 组件、自定义扩展包等。项目名称为 "play",主要用于创建交互式的教育类游戏内容。
## 整体架构
```
testzg001/
├── 核心游戏引擎 (Cocos Creator)
├── 构建和发布系统 (Node.js)
├── 表单编辑器 (HTML/JavaScript + Angular)
├── 自定义扩展包 (Cocos Creator Extensions)
└── 配置和设置文件
```
## 详细模块分析
### 1. 项目根目录结构
#### 1.1 核心配置文件
- **package.json**: Node.js 项目配置,定义了构建脚本和依赖
- 主要脚本: `publish`(构建)、`start`(启动服务器)
- 核心依赖: express、compressing、uuid、base-64
- **project.json**: Cocos Creator 项目配置
- 引擎版本: cocos-creator-js 2.4.5
- 项目ID: 9af72fd2-44a6-4131-8ea3-3e1b3fa22231
- **tsconfig.json**: TypeScript 编译配置
- 目标: ES5,支持装饰器和CommonJS模块
#### 1.2 构建系统 (/bin/)
- **app.js**: 开发服务器
- 启动Express服务器 (端口8081)
- 提供静态文件服务 (/dist, /form)
- 支持交互式构建命令
- **build.js**: 构建入口脚本
- **buildCocos.js**: 核心构建逻辑 (444行)
- 支持多平台构建 (Web、Android、iOS)
- 资源压缩和UUID替换
- 表单组件构建集成
- **utils.js**: 构建工具函数
### 2. Cocos Creator 游戏资源 (/assets/)
#### 2.1 资源组织结构
```
assets/cocos_generator/
├── audios/ # 音频资源
│ └── btn.mp3 # 按钮音效
├── dragonBones/ # 骨骼动画资源
├── fonts/ # 字体资源
│ └── BRLNSDB.TTF # 自定义字体
├── scene/ # 场景文件
│ ├── cocos_generator.fire # 主场景
│ └── cocos_generator.ts # 场景脚本
├── script/ # 脚本文件
│ ├── MyCocosSceneComponent.ts # 基础场景组件
│ ├── defaultData.ts # 默认数据配置
│ ├── runtime.js # 运行时脚本
│ └── util.ts # 工具函数
└── textures/ # 纹理资源
├── bg.jpg # 背景图
├── icon.png # 图标
└── btn_*.png # 按钮纹理
```
#### 2.2 核心脚本架构
- **MyCocosSceneComponent.ts**: 基础场景组件类
- 屏幕适配逻辑
- 资源预加载管理
- 通用工具方法
- **cocos_generator.ts**: 主场景控制器
- 继承自MyCocosSceneComponent
- 实现具体的游戏逻辑
- 支持左右切换功能
### 3. 表单编辑器系统
#### 3.1 HTML版本 (/form/)
- **index.html**: 基于ACE编辑器的JSON配置界面
- 集成ACE代码编辑器
- 支持文件上传功能
- 实时数据同步到courseware系统
- **ace/**: ACE编辑器相关文件
- 支持JavaScript和JSON语法高亮
- Chrome主题配置
#### 3.2 Angular版本 (/form_angular/)
- **技术栈**: Angular 9.0.2 + ng-zorro-antd UI组件库
- **核心功能**:
- 现代化的表单编辑界面
- 支持文件上传和压缩
- 集成阿里云OSS存储
- **构建配置**:
- 支持AOT编译和构建优化
- 自定义发布脚本
### 4. 自定义扩展包 (/packages/)
#### 4.1 check-file-name
- **功能**: 文件名检查工具
- **用途**: 确保资源文件命名规范
#### 4.2 replace-uuid
- **功能**: UUID替换工具
- **用途**: 批量替换资源UUID引用
#### 4.3 引用查找器 (ccc-references-finder)
- **版本**: 1.3.0.20210929
- **功能**: 资源引用关系查找
- **特性**:
- 一键查找资源的所有引用
- 精确到预制体或场景中的节点、组件和属性
- 支持快捷键操作 (F6)
### 5. 项目配置 (/settings/)
#### 5.1 builder.json
- **构建配置**:
- 应用名称: "play"
- 包名: org.cocos2d.demo
- 支持横屏模式
- 启用JS加密 (xxteaKey)
- 支持多平台发布
#### 5.2 project.json
- **项目设置**: 记录模块事件和迁移历史
## 技术特点
### 1. 多平台支持
- Web端游戏运行
- Android/iOS原生应用
- 桌面端 (Mac/Windows)
### 2. 开发工具集成
- 实时预览服务器
- 自动化构建流程
- 资源管理工具
- 代码编辑器集成
### 3. 资源管理
- 统一的资源预加载机制
- UUID管理和替换
- 文件压缩和优化
- 多格式资源支持
### 4. 扩展性设计
- 插件化的扩展包系统
- 模块化的脚本架构
- 可配置的构建流程
## 开发流程
1. **资源准备**: 在assets目录下组织游戏资源
2. **脚本开发**: 基于MyCocosSceneComponent开发游戏逻辑
3. **配置编辑**: 使用form编辑器配置游戏参数
4. **构建发布**: 通过npm scripts执行构建
5. **测试验证**: 使用内置服务器进行测试
## 部署架构
```
开发环境 → 构建系统 → 静态资源 → CDN分发
↓ ↓ ↓ ↓
源码编辑 资源压缩 文件托管 用户访问
```
## 总结
该项目是一个功能完整的Cocos Creator游戏开发框架,具有以下优势:
1. **完整的工具链**: 从开发到发布的完整流程支持
2. **多端适配**: 支持Web、移动端、桌面端多平台
3. **可视化配置**: 提供友好的配置编辑界面
4. **扩展性强**: 支持自定义扩展包和插件
5. **自动化程度高**: 集成构建、压缩、发布等自动化流程
该架构适合用于开发教育类交互游戏、H5小游戏等项目,具有良好的可维护性和扩展性。
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "c35bb2f6-f24a-4850-ae44-643f2fdc7541",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {
"ios": false,
"android": false
},
"subMetas": {}
}
\ No newline at end of file
import { asyncDelay, onHomeworkFinish } from "../script/util";
import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent";
const { ccclass, property } = cc._decorator;
@ccclass
export default class SceneComponent extends MyCocosSceneComponent {
addPreloadImage() {
// TODO 根据自己的配置预加载图片资源
this._imageResList.push({ url: this.data.pic_url });
this._imageResList.push({ url: this.data.pic_url_2 });
}
addPreloadAudio() {
// TODO 根据自己的配置预加载音频资源
this._audioResList.push({ url: this.data.audio_url });
}
addPreloadAnima() {
}
async onLoadEnd() {
// TODO 加载完成后的逻辑写在这里, 下面的代码仅供参考
this.initData();
this.initView();
this.initListener();
}
_cantouch = null;
initData() {
// 所有全局变量 默认都是null
this._cantouch = true;
}
initView() {
this.initBg();
this.initPic();
this.initBtn();
this.initIcon();
}
initBg() {
const bgNode = cc.find('Canvas/bg');
bgNode.scale = this._mapScaleMax;
}
pic1 = null;
pic2 = null;
initPic() {
const canvas = cc.find('Canvas');
const maxW = canvas.width * 0.7;
this.getSprNodeByUrl(this.data.pic_url, (sprNode) => {
const picNode1 = sprNode;
picNode1.scale = maxW / picNode1.width;
picNode1.baseX = picNode1.x;
canvas.addChild(picNode1);
this.pic1 = picNode1;
const labelNode = new cc.Node();
labelNode.color = cc.Color.YELLOW;
const label = labelNode.addComponent(cc.Label);
label.string = this.data.text;
label.fontSize = 60;
label.lineHeight = 60;
label.font = cc.find('Canvas/res/font/BRLNSDB').getComponent('cc.Label').font;
picNode1.addChild(labelNode);
});
this.getSprNodeByUrl(this.data.pic_url_2, (sprNode) => {
const picNode2 = sprNode;
picNode2.scale = maxW / picNode2.width;
canvas.addChild(picNode2);
picNode2.x = canvas.width;
picNode2.baseX = picNode2.x;
this.pic2 = picNode2;
const labelNode = new cc.Node();
const label = labelNode.addComponent(cc.RichText);
const size = 60
label.font = cc.find('Canvas/res/font/BRLNSDB').getComponent(cc.Label).font;
label.string = `<outline color=#751e00 width=4><size=${size}><color=#ffffff>${this.data.text}</color></size></outline>`
label.lineHeight = size;
picNode2.addChild(labelNode);
});
}
initIcon() {
const iconNode = this.getSprNode('icon');
iconNode.zIndex = 5;
iconNode.anchorX = 1;
iconNode.anchorY = 1;
iconNode.parent = cc.find('Canvas');
iconNode.x = iconNode.parent.width / 2 - 10;
iconNode.y = iconNode.parent.height / 2 - 10;
iconNode.on(cc.Node.EventType.TOUCH_START, () => {
this.playAudioByUrl(this.data.audio_url);
})
}
curPage = null;
initBtn() {
this.curPage = 0;
const bottomPart = cc.find('Canvas/bottomPart');
bottomPart.zIndex = 5; // 提高层级
bottomPart.x = bottomPart.parent.width / 2;
bottomPart.y = -bottomPart.parent.height / 2;
const leftBtnNode = bottomPart.getChildByName('btn_left');
//节点中添加了button组件 则可以添加click事件监听
leftBtnNode.on('click', () => {
if (!this._cantouch) {
return;
}
if (this.curPage == 0) {
return;
}
this.curPage = 0
this.leftMove();
this.playLocalAudio('btn');
})
const rightBtnNode = bottomPart.getChildByName('btn_right');
//节点中添加了button组件 则可以添加click事件监听
rightBtnNode.on('click', () => {
if (!this._cantouch) {
return;
}
if (this.curPage == 1) {
return;
}
this.curPage = 1
this.rightMove();
// 游戏结束时需要调用这个方法通知系统作业完成
onHomeworkFinish();
this.playLocalAudio('btn');
})
}
leftMove() {
this._cantouch = false;
const len = this.pic1.parent.width;
cc.tween(this.pic1)
.to(1, { x: this.pic1.baseX }, { easing: 'cubicInOut' })
.start();
cc.tween(this.pic2)
.to(1, { x: this.pic2.baseX }, { easing: 'cubicInOut' })
.call(() => {
this._cantouch = true;
})
.start();
}
rightMove() {
this._cantouch = false;
const len = this.pic1.parent.width;
cc.tween(this.pic1)
.to(1, { x: this.pic1.baseX - len }, { easing: 'cubicInOut' })
.start();
cc.tween(this.pic2)
.to(1, { x: this.pic2.baseX - len }, { easing: 'cubicInOut' })
.call(() => {
this._cantouch = true;
})
.start();
}
// update (dt) {},
initListener() {
}
playLocalAudio(audioName) {
const audio = cc.find(`Canvas/res/audio/${audioName}`).getComponent(cc.AudioSource);
return new Promise((resolve, reject) => {
const id = cc.audioEngine.playEffect(audio.clip, false);
cc.audioEngine.setFinishCallback(id, () => {
resolve(id);
});
})
}
}
import { defaultData } from "../script/defaultData";
export class MyCocosSceneComponent extends cc.Component {
// 生命周期 onLoad
onLoad() {
this.initSceneData();
this.initSize();
}
_imageResList = null;
_audioResList = null;
_animaResList = null;
initSceneData() {
this._imageResList = [];
this._audioResList = [];
this._animaResList = [];
}
_designSize = null; // 设计分辨率
_frameSize = null; // 屏幕分辨率
_mapScaleMin = null; // 场景中常用缩放(取大值)
_mapScaleMax = null; // 场景中常用缩放(取小值)
_cocosScale = null; // cocos 自缩放 (较少用到)
initSize() {
// 注意cc.winSize只有在适配后(修改fitHeight/fitWidth后)才能获取到正确的值,因此使用cc.getFrameSize()来获取初始的屏幕大小
let screen_size = cc.view.getFrameSize().width / cc.view.getFrameSize().height
let design_size = cc.Canvas.instance.designResolution.width / cc.Canvas.instance.designResolution.height
let f = screen_size >= design_size
cc.Canvas.instance.fitHeight = f
cc.Canvas.instance.fitWidth = !f
const frameSize = cc.view.getFrameSize();
this._frameSize = frameSize;
this._designSize = cc.view.getDesignResolutionSize();
let sx = cc.winSize.width / frameSize.width;
let sy = cc.winSize.height / frameSize.height;
this._cocosScale = Math.min(sx, sy);
sx = frameSize.width / this._designSize.width;
sy = frameSize.height / this._designSize.height;
this._mapScaleMin = Math.min(sx, sy) * this._cocosScale;
this._mapScaleMax = Math.max(sx, sy) * this._cocosScale;
cc.director['_scene'].width = frameSize.width;
cc.director['_scene'].height = frameSize.height;
}
data = null;
// 生命周期 start
start() {
if (window && (<any>window).courseware && (<any>window).courseware.getData) {
(<any>window).courseware.getData((data) => {
this.log('data:' + data);
this.data = data || this.getDefaultData();
this.data = JSON.parse(JSON.stringify(this.data));
this.preloadItem();
})
} else {
this.data = this.getDefaultData();
this.preloadItem();
}
}
getDefaultData() {
return defaultData;
}
preloadItem() {
this.addPreloadImage();
this.addPreloadAudio();
this.addPreloadAnima();
this.preload();
}
addPreloadImage() {
}
addPreloadAudio() {
}
addPreloadAnima() {
}
preload() {
const preloadArr = this._imageResList.concat(this._audioResList).concat(this._animaResList);
cc.assetManager.preloadAny(preloadArr, null, null, async (err, data) => {
if (window && window["air"]) {
// window["air"].onCourseInScreen = (next) => {
// window["air"].isCourseInScreen = true;
// this.onLoadEnd();
// next();
// };
await this.onLoadEnd();
window["air"].hideAirClassLoading();
} else {
await this.onLoadEnd();
}
cc.debug.setDisplayStats(false);
});
}
log (str) {
const node = cc.find('middleLayer');
if(node){
node.getComponent('middleLayer').log(str);
}else{
console.log(str);
}
}
async onLoadEnd() {
}
// ------------------------------------------------
getSprNode(resName) {
const sf = cc.find('Canvas/res/img/' + resName).getComponent(cc.Sprite).spriteFrame;
const node = new cc.Node();
node.addComponent(cc.Sprite).spriteFrame = sf;
return node;
}
getSpriteFrimeByUrl(url, cb) {
cc.loader.load({ url }, (err, img) => {
const spriteFrame = new cc.SpriteFrame(img)
if (cb) {
cb(spriteFrame);
}
})
}
getSprNodeByUrl(url, cb) {
const node = new cc.Node();
const spr = node.addComponent(cc.Sprite);
this.getSpriteFrimeByUrl(url, (sf) => {
spr.spriteFrame = sf;
if (cb) {
cb(node);
}
})
}
playAudioByUrl(audio_url, cb = null) {
if (audio_url) {
cc.assetManager.loadRemote(audio_url, (err, audioClip) => {
const audioId = cc.audioEngine.play(audioClip, false, 0.8);
if (cb) {
cc.audioEngine.setFinishCallback(audioId, () => {
cb();
});
}
});
}else{
cb && cb();
}
}
}
\ No newline at end of file
export const defaultData = {
"pic_url": "http://staging-teach.cdn.ireadabc.com/ed94332a503c31e0908bd4c6923a2665.png",
"pic_url_2": "http://staging-teach.cdn.ireadabc.com/5fb60317ade0195d35ad8034d5370a7f.png",
"text": "This is a test label.",
"audio_url": "http://staging-teach.cdn.ireadabc.com/f47f1d7b5c160fe1c59500d180346240.mp3"
}
\ No newline at end of file
{"ver":"1.1.2","uuid":"1686a536-c3b6-4b5a-80f1-7463f4cae6a5","isBundle":false,"bundleName":"","priority":1,"compressionType":{},"optimizeHotUpdate":{},"inlineSpriteFrames":{},"isRemoteBundle":{"ios":false,"android":false},"subMetas":{}}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "c1c7aa37-d5f2-4e61-ab25-d4b5732e4cd1",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.0",
"uuid": "f56fa781-c669-41b5-bc8e-d5be1eb47dee",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.0.1",
"uuid": "9ed337e6-1383-4c20-8e79-a2fbc2239e2a",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "9a79969a-0506-48d4-bc98-3c05d109b027",
"uuid": "73732d0a-dcb7-44b6-874f-086ea4f54309",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 61,
"height": 67,
"width": 68,
"height": 68,
"platformSettings": {},
"subMetas": {
"btn_left": {
"icon_back": {
"ver": "1.0.4",
"uuid": "ce19457d-e8f3-4c38-ae3e-d4b99208ddb5",
"rawTextureUuid": "9a79969a-0506-48d4-bc98-3c05d109b027",
"uuid": "46e12222-42d0-43df-871d-649907921d4b",
"rawTextureUuid": "73732d0a-dcb7-44b6-874f-086ea4f54309",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
......@@ -22,10 +22,10 @@
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 61,
"height": 67,
"rawWidth": 61,
"rawHeight": 67,
"width": 68,
"height": 68,
"rawWidth": 68,
"rawHeight": 68,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
......
{
"ver": "1.1.2",
"uuid": "cb9fa4ea-66ca-45af-ad31-e445c7b0ef32",
"uuid": "df398969-043a-46b8-a182-8f42a11d4e91",
"isBundle": false,
"bundleName": "",
"priority": 1,
......
{
"ver": "2.0.1",
"uuid": "f0680ae0-c079-45ef-abd7-9e63d90b982b",
"uuid": "cfed0c98-4105-4f50-8546-817cabe20abe",
"downloadMode": 0,
"duration": 0.130612,
"subMetas": {}
......
{
"ver": "2.0.1",
"uuid": "4df12ceb-53ae-41da-9c91-41b5d93a69fe",
"downloadMode": 0,
"duration": 1.906939,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "0853721c-3f55-4eb2-873d-e3081cfadd4b",
"uuid": "63e27add-ff0f-49ad-a484-9c49bef0adf0",
"isBundle": false,
"bundleName": "",
"priority": 1,
......
{
"ver": "1.1.2",
"uuid": "20185448-a1ca-4de2-8b37-7bf6cdfccbae",
"uuid": "ab2b5106-5f1b-4f0a-ac40-5b7627d68faf",
"isBundle": false,
"bundleName": "",
"priority": 1,
......
{
"ver": "1.1.0",
"uuid": "c551970e-b095-45f3-9f1d-25cde8b8deb1",
"uuid": "40eafa10-aafb-4187-8b4e-7fcd3de589b7",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "15ea1f16-5a4b-4673-bd95-839b1eeec196",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "bb13ab32-5a7b-4f26-aaa6-972cbebec8a6",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.2.9",
"uuid": "d3b32dd0-821a-47cb-af4b-fda13607e2ac",
"asyncLoadAssets": false,
"autoReleaseAssets": false,
"subMetas": {}
}
\ No newline at end of file
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
const {ccclass, property} = cc._decorator;
@ccclass
export default class NewClass extends cc.Component {
// LIFE-CYCLE CALLBACKS:
// onLoad () {}
start () {
}
onRunGameCenter() {
cc.director.loadScene('middleLayer_for_jxw_demo');
}
// update (dt) {}
}
{
"ver": "1.0.8",
"uuid": "f8b451ff-857c-4ca8-9870-866bc5154a29",
"uuid": "cd4e17dc-c834-48dc-8963-509c194aa289",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
......
{
"ver": "1.1.2",
"uuid": "d7831902-c653-4034-ba91-dcac51401b90",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
# 游戏中心进度条功能说明
## 功能概述
为游戏中心页面添加了进度条功能,在调用`loadPageBundle`加载游戏资源时显示进度条,加载完成后自动隐藏。
## 主要特性
- 自动创建进度条UI组件
- 实时显示加载进度
- 支持通过属性面板自定义进度条样式
- 包含模拟进度功能作为备用方案
- 自动重写middleLayer组件的进度更新方法
## 使用方法
### 1. 自动创建进度条
进度条会在页面初始化时自动创建,无需手动配置。
### 2. 通过属性面板自定义
如果需要在编辑器中自定义进度条样式,可以在属性面板中设置以下属性:
- `progressBarContainer`: 进度条容器节点
- `progressBar`: 进度条组件
- `progressLabel`: 进度文本标签
### 3. 进度条显示时机
- 当用户点击游戏卡片时自动显示
-`loadPageBundle`调用期间保持显示
- 加载完成后自动隐藏
## 技术实现
### 进度条组件结构
```
progress_bar_container (容器)
├── bg_mask (背景遮罩)
├── loading_label (加载提示文本)
├── progress_bg (进度条背景)
├── progress_bar (进度条)
└── progress_label (进度百分比文本)
```
### 关键方法
- `showProgressBar()`: 显示进度条
- `hideProgressBar()`: 隐藏进度条
- `updateProgressBar(progress)`: 更新进度值
- `overrideProgressUpdate()`: 重写middleLayer的进度更新方法
- `startSimulatedProgress()`: 启动模拟进度更新
- `stopSimulatedProgress()`: 停止模拟进度更新
### 进度更新机制
1. **实际进度更新**: 通过重写middleLayer组件的`setLoadingProgressBar`方法
2. **模拟进度更新**: 作为备用方案,确保用户能看到进度变化
3. **自动隐藏**: 在`loadPageBundle`回调中自动隐藏进度条
## 样式配置
- 进度条容器尺寸: 400x120
- 进度条尺寸: 300x20
- 背景遮罩: 半透明黑色
- 进度条颜色: 蓝色
- 文本颜色: 白色
## 注意事项
1. 进度条会在页面初始化时自动创建
2. 模拟进度最多显示到90%,留10%给实际加载完成
3. 如果middleLayer组件没有正确调用进度更新,模拟进度会作为备用方案
4. 进度条会在加载完成后自动清理和隐藏
## 扩展功能
如需添加更多功能,可以考虑:
- 添加取消加载按钮
- 显示预计剩余时间
- 添加加载失败重试机制
- 自定义进度条动画效果
\ No newline at end of file
{
"ver": "2.0.0",
"uuid": "84e43972-36f8-466c-b783-10b9741bc9c4",
"subMetas": {}
}
\ No newline at end of file
# 游戏广场界面设置说明
## 概述
这个界面实现了一个游戏广场,显示8个游戏卡片的横滑列表,每个卡片包含游戏缩略图和标题。
## 节点结构
### 1. 主要节点层级
```
Canvas (1920x1080)
├── bg (背景 - 浅色背景)
├── back_btn (返回按钮 - 左上角)
├── header (标题栏)
│ └── title_label (游戏广场标题)
└── game_list_container (游戏列表容器)
└── scroll_view (滚动视图)
└── content (内容节点 - 包含所有游戏卡片)
```
### 2. 游戏卡片结构
```
game_card (300x400)
├── card_bg (卡片背景 - 白色圆角矩形)
├── game_thumbnail (游戏缩略图 - 260x280)
└── game_title (游戏标题 - 280x60)
```
## 在Cocos Creator中的设置步骤
### 步骤1: 创建主要节点
1. 在Canvas下创建以下节点:
- `bg` (Sprite) - 设置浅色背景
- `back_btn` (Button) - 返回按钮,已存在
- `header` (Node) - 标题栏容器
- `game_list_container` (Node) - 游戏列表容器
### 步骤2: 设置标题栏
1.`header`节点下创建:
- `title_label` (Label) - 设置文本为"游戏广场"
- 字体大小:32,颜色:黑色
- 位置:居中显示
### 步骤3: 设置滚动视图
1.`game_list_container`下创建:
- `scroll_view` (ScrollView组件)
- 设置ScrollView属性:
- Content: 创建content子节点
- Horizontal: true (允许水平滚动)
- Vertical: false (禁用垂直滚动)
- Elastic Top/Bottom: 0
- Elastic Left/Right: 0.1
### 步骤4: 设置内容节点
1.`scroll_view`下创建`content`节点
2. 设置content节点属性:
- Anchor Point: (0, 0.5)
- Position: (0, 0)
### 步骤5: 创建游戏卡片预制体(推荐)
1. 创建新的预制体文件:`game-card.prefab`
2. 在预制体中创建卡片结构:
- 根节点:300x400
- `card_bg`: 白色背景,300x400
- `game_thumbnail`: 缩略图容器,260x280,位置(0, 60)
- `game_title`: 标题标签,280x60,位置(0, -160)
3. 添加`GameCard`组件到根节点
4. 在组件中绑定对应的属性引用
### 步骤6: 配置脚本组件
1. 在Canvas节点上添加`GameCenter`脚本组件
2. 在脚本组件中设置属性:
- `gameListContainer`: 拖拽`game_list_container`节点
- `gameCardPrefab`: 拖拽`game-card.prefab`预制体
- `scrollView`: 拖拽`scroll_view`节点
## 样式设置
### 颜色方案
- 背景色:浅色 (#F8F6EF)
- 卡片背景:白色 (#FFFFFF)
- 标题文字:黑色 (#000000)
### 尺寸规格
- 卡片尺寸:300x400
- 卡片间距:30px
- 缩略图尺寸:260x280
- 标题区域:280x60
### 字体设置
- 标题字体:24px
- 行高:30px
- 对齐方式:居中对齐
## 功能特性
1. **自动加载游戏数据**:从API接口获取游戏列表
2. **动态创建卡片**:根据数据自动生成游戏卡片
3. **横滑滚动**:支持触摸滑动浏览所有游戏
4. **点击交互**:每个卡片都可以点击,触发相应事件
5. **响应式布局**:自动计算内容宽度,适配不同数量的游戏
## 注意事项
1. 确保网络接口正常工作,能够获取游戏数据
2. 游戏封面图片需要能够正常加载
3. 如果使用预制体,确保路径和引用正确
4. 滚动视图的content节点大小会根据游戏数量自动调整
5. 建议在真机上测试触摸滑动效果
## 扩展功能
1. **搜索功能**:可以添加搜索框过滤游戏
2. **分类功能**:按游戏类型分组显示
3. **收藏功能**:允许用户收藏喜欢的游戏
4. **最近游戏**:显示最近玩过的游戏
5. **游戏统计**:显示游戏完成度等信息
\ No newline at end of file
{
"ver": "2.0.0",
"uuid": "eb73ef0e-b62d-4076-bdb5-10b160d3c349",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "ba6fe9d5-1e01-47aa-a873-c0fd4aac603b",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "efa5fa09-a4dd-4bfc-ab7e-17c19f85408f",
"uuid": "3aa1719b-00cc-41db-bfb0-4e7d2555744b",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 366,
"height": 336,
"width": 360,
"height": 259,
"platformSettings": {},
"subMetas": {
"1orange": {
"bg_card": {
"ver": "1.0.4",
"uuid": "43d1e79d-6de8-4dcb-b8ce-d767df7913aa",
"rawTextureUuid": "efa5fa09-a4dd-4bfc-ab7e-17c19f85408f",
"uuid": "de6f866b-94c7-4ed9-a24f-db71d9e23f83",
"rawTextureUuid": "3aa1719b-00cc-41db-bfb0-4e7d2555744b",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": -0.5,
"offsetY": 0,
"trimX": 0,
"trimY": 1,
"width": 366,
"height": 335,
"rawWidth": 366,
"rawHeight": 336,
"trimY": 0,
"width": 360,
"height": 259,
"rawWidth": 360,
"rawHeight": 259,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
......
{
"ver": "2.3.5",
"uuid": "d582359e-924e-4ee9-9964-1fc4bb417e71",
"uuid": "eb3060d1-7cea-4da3-af43-01697d3a7a6f",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 61,
"height": 67,
"width": 68,
"height": 68,
"platformSettings": {},
"subMetas": {
"btn_right": {
"icon_back": {
"ver": "1.0.4",
"uuid": "e5a2dbaa-a677-4a32-90d7-a1b057d7fb59",
"rawTextureUuid": "d582359e-924e-4ee9-9964-1fc4bb417e71",
"uuid": "c30f8209-aafd-44dd-9cb6-56853524b753",
"rawTextureUuid": "eb3060d1-7cea-4da3-af43-01697d3a7a6f",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -0.5,
"offsetY": 0.5,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 60,
"height": 66,
"rawWidth": 61,
"rawHeight": 67,
"width": 68,
"height": 68,
"rawWidth": 68,
"rawHeight": 68,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
......
const {ccclass, property} = cc._decorator;
interface GameCardData {
id: number;
uuid: string;
template_name: string;
template_description: string;
cover: string;
cw_cover: string;
data: string;
seq: number;
}
@ccclass
export default class GameCard extends cc.Component {
@property(cc.Sprite)
thumbnailSprite: cc.Sprite = null;
@property(cc.Label)
titleLabel: cc.Label = null;
@property(cc.Node)
cardBg: cc.Node = null;
private gameData: GameCardData = null;
onLoad() {
// 添加点击事件
this.node.on('click', this.onCardClick, this);
}
public init(data: GameCardData) {
this.gameData = data;
this.updateDisplay();
}
private updateDisplay() {
if (!this.gameData) return;
// 设置标题
if (this.titleLabel) {
this.titleLabel.string = this.gameData.template_description || '未知游戏';
}
// 加载并设置缩略图
if (this.thumbnailSprite && (this.gameData.cover || this.gameData.cw_cover)) {
const cv = this.gameData.cw_cover ? this.gameData.cw_cover : this.gameData.cover;
cc.loader.load(cv, (err, texture) => {
if (!err && texture) {
const spriteFrame = new cc.SpriteFrame(texture);
this.thumbnailSprite.spriteFrame = spriteFrame;
}
});
}
}
private onCardClick() {
if (this.gameData) {
console.log('点击游戏卡片:', this.gameData.template_description);
// 派发事件通知父节点
this.node.emit('onGameCardClick', this.gameData);
}
}
onDestroy() {
this.node.off('click', this.onCardClick, this);
}
}
\ No newline at end of file
{
"ver": "1.0.8",
"uuid": "c41b0e51-55d7-443c-af3a-b22c3dd9b9e5",
"uuid": "f2c660aa-4071-4adf-b242-bfafeee322bb",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
......
This diff is collapsed.
{
"ver": "1.2.9",
"uuid": "27eb256f-ec8a-434e-b7e6-7586858ed26c",
"asyncLoadAssets": false,
"autoReleaseAssets": false,
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.0.8",
"uuid": "408a67f8-65fa-4cf1-8cf2-83e20e1a0fd5",
"uuid": "313c5a50-d15d-4cc6-9ba2-f3087152c003",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
......
{
"ver": "1.1.2",
"uuid": "be3662af-05a2-4566-819b-72bb7be37e2f",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
[
{
"__type__": "cc.Prefab",
"_name": "",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"asyncLoadAssets": false,
"readonly": false
},
{
"__type__": "cc.Node",
"_name": "game-card",
"_objFlags": 0,
"_parent": null,
"_children": [
{
"__id__": 2
},
{
"__id__": 5
},
{
"__id__": 8
}
],
"_active": true,
"_components": [
{
"__id__": 11
},
{
"__id__": 12
}
],
"_prefab": {
"__id__": 13
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 410,
"height": 259
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Node",
"_name": " card_bg",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": false,
"_components": [
{
"__id__": 3
}
],
"_prefab": {
"__id__": 4
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 360,
"height": 259
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "de6f866b-94c7-4ed9-a24f-db71d9e23f83"
},
"_type": 0,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "9d1c550e-eadd-4e95-b5db-2e10893000fc"
},
"fileId": "85oivK5FhAvZPML5eAXr4v",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "game_thumbnail",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 6
}
],
"_prefab": {
"__id__": 7
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 410,
"height": 269
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
21.754,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 5
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": null,
"_type": 1,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "9d1c550e-eadd-4e95-b5db-2e10893000fc"
},
"fileId": "e9n/ZFueBHlJMia+chDdd0",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "game_title",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": false,
"_components": [
{
"__id__": 9
}
],
"_prefab": {
"__id__": 10
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 325,
"height": 40.32
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-1.089,
-103.039,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Label",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 8
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_string": "",
"_N$string": "",
"_fontSize": 22,
"_lineHeight": 22,
"_enableWrapText": true,
"_N$file": null,
"_isSystemFontUsed": true,
"_spacingX": 0,
"_batchAsBitmap": false,
"_styleFlags": 0,
"_underlineHeight": 0,
"_N$horizontalAlign": 0,
"_N$verticalAlign": 0,
"_N$fontFamily": "Arial",
"_N$overflow": 1,
"_N$cacheMode": 0,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "9d1c550e-eadd-4e95-b5db-2e10893000fc"
},
"fileId": "baz8Zjv3ZPzbAiy2HWukQu",
"sync": false
},
{
"__type__": "f2c66CqQHFK37JCv6/u4yK7",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"thumbnailSprite": {
"__id__": 6
},
"titleLabel": {
"__id__": 9
},
"cardBg": {
"__id__": 2
},
"_id": ""
},
{
"__type__": "cc.Button",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"_normalMaterial": null,
"_grayMaterial": null,
"duration": 0.1,
"zoomScale": 1.2,
"clickEvents": [],
"_N$interactable": true,
"_N$enableAutoGrayEffect": false,
"_N$transition": 0,
"transition": 0,
"_N$normalColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_N$pressedColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"pressedColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"_N$hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_N$disabledColor": {
"__type__": "cc.Color",
"r": 124,
"g": 124,
"b": 124,
"a": 255
},
"_N$normalSprite": null,
"_N$pressedSprite": null,
"pressedSprite": null,
"_N$hoverSprite": null,
"hoverSprite": null,
"_N$disabledSprite": null,
"_N$target": {
"__id__": 1
},
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "9d1c550e-eadd-4e95-b5db-2e10893000fc"
},
"fileId": "",
"sync": false
}
]
\ No newline at end of file
{
"ver": "1.2.9",
"uuid": "9d1c550e-eadd-4e95-b5db-2e10893000fc",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "e8bd16b0-3804-45a9-a8ca-f52c02224f55",
"uuid": "343772d3-b73e-4f27-802c-778c15ab200a",
"isBundle": false,
"bundleName": "",
"priority": 1,
......
{
"ver": "1.2.9",
"uuid": "0737ce42-24f0-45c6-8e1a-8bdab4f74ba3",
"uuid": "02722d5a-cf9a-487c-af02-dbe014969446",
"asyncLoadAssets": false,
"autoReleaseAssets": true,
"subMetas": {}
......
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
const {ccclass, property} = cc._decorator;
@ccclass
export default class NewClass extends cc.Component {
// LIFE-CYCLE CALLBACKS:
// onLoad () {}
start () {
}
// update (dt) {}
}
{
"ver": "1.0.8",
"uuid": "25b7b75d-bda3-4f9d-ae75-729cb509b029",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.2.9",
"uuid": "ef994a81-2c20-4807-94bb-4a893002b8c8",
"asyncLoadAssets": false,
"autoReleaseAssets": true,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "b0c008bc-cf92-463b-8360-0984e13c2e4d",
"uuid": "604a9f3a-da45-44af-b464-2d004dec1cf9",
"isBundle": false,
"bundleName": "",
"priority": 1,
......
cc.Class({
extends: cc.Component,
onDestroy() {
console.log('喵喵喵: destroyer onDestroy');
middleLayer.clearDragonDisplayAssetList();
}
});
{
"ver": "1.0.8",
"uuid": "1006faef-f150-4f13-abe6-7d83a28222a4",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.0.8",
"uuid": "2dc212ff-46a3-46f8-9570-e72d19a0bca1",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.0.8",
"uuid": "e6cecd33-7ff6-4b68-a154-37af4b62af86",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.0.8",
"uuid": "b54300af-b8e5-4b4e-aa2f-9ac1cef7b598",
"uuid": "2a83e863-1b62-407f-b40d-d4380c5630b7",
"isPlugin": true,
"loadPluginInWeb": true,
"loadPluginInNative": true,
......
......@@ -177,85 +177,15 @@ export function playAudio(audioClip, cb = null) {
export async function asyncDelay(time) {
return new Promise((resolve, reject) => {
try {
cc.tween(cc.find('Canvas'))
.delay(time)
.call(()=>{
resolve(null);
})
.start();
setTimeout(() => {
resolve(null);
}, time * 1000);
} catch (e) {
reject(e);
}
})
}
export async function asyncLoadDragonBoneAnime(node, { skeJsonData: { url: skeJsonDataUrl }, texJsonData: { url: texJsonDataUrl }, texPngData: { url: texPngDataUrl } }) {
if (!texPngDataUrl || !texJsonDataUrl || !texPngDataUrl
|| texPngDataUrl == '' || texJsonDataUrl == '' || texPngDataUrl == '') {
return;
}
return new Promise((resolve, reject) => {
if (node.animaNode) {
node.animaNode.removeFromParent();
}
const animaNode = new cc.Node();
animaNode.name = 'animaNode';
animaNode.parent = node;
animaNode.active = true;
node.animaNode = animaNode;
const dragonDisplay = animaNode.addComponent(dragonBones.ArmatureDisplay);
const loadTexture = new Promise((resolve, reject) => {
cc.assetManager.loadRemote(texPngDataUrl, (error, texture) => {
if (error) {
reject(error);
}
resolve(texture);
});
});
const loadTexJsonData = new Promise((resolve, reject) => {
cc.assetManager.loadAny({ url: texJsonDataUrl }, (error, atlasJson) => {
if (error) {
reject(error);
}
resolve(atlasJson);
});
});
const loadSkeJsonData = new Promise((resolve, reject) => {
cc.assetManager.loadAny({ url: skeJsonDataUrl }, (error, dragonBonesJson) => {
if (error) {
reject(error);
}
resolve(dragonBonesJson);
});
});
Promise.all([loadTexture, loadTexJsonData, loadSkeJsonData]).then(([texture, atlasJson, dragonBonesJson]) => {
const atlas = new dragonBones.DragonBonesAtlasAsset();
atlas.atlasJson = JSON.stringify(atlasJson);
atlas.texture = texture;
const asset = new dragonBones.DragonBonesAsset();
asset.dragonBonesJson = JSON.stringify(dragonBonesJson);
dragonDisplay.dragonAtlasAsset = atlas;
dragonDisplay.dragonAsset = asset;
let armatureNames = dragonBonesJson.armature.map(data => data.name);
if (armatureNames.length > 0) {
dragonDisplay.armatureName = armatureNames[0];
}
resolve(animaNode);
});
});
}
export class FireworkSettings {
baseNode; // 父节点
nodeList; // 火花节点的array
......@@ -411,65 +341,14 @@ export function showTrebleFirework(baseNode, rabbonList) {
showFireworks(right);
}
export function httpHeadCall(requsetUrl: string, callback) {
let xhr = new XMLHttpRequest();
console.log("Status: Send Post Request to " + requsetUrl);
try {
xhr.onreadystatechange = () => {
try {
console.log('xhr.readyState: ', xhr.readyState);
if (xhr.readyState == 4) {
if ((xhr.status >= 200 && xhr.status < 400)) {
callback(true);
} else {
callback(false);
}
}
} catch (e) {
console.log(e)
}
};
xhr.open("HEAD", requsetUrl, true);
xhr.send();
xhr.timeout = 15000;
xhr.onerror = (e) => {
callback(false);
};
xhr.ontimeout = (e) => {
callback(false);
};
} catch (e) {
console.log("Send Get Request error: ", e);
}
}
export function onHomeworkFinish(data = "", callback = ()=>{}) {
const middleLayer = cc.find('middleLayer');
if (middleLayer) {
const middleLayerComponent = middleLayer.getComponent('middleLayer');
middleLayerComponent.onHomeworkFinish(callback, data);
} else {
console.log('onHomeworkFinish', JSON.stringify(data));
}
}
export function callMiddleLayerFunction(apiName: string, data: any, callback: Function) {
export function onHomeworkFinish() {
const middleLayer = cc.find('middleLayer');
if (middleLayer) {
const middleLayerComponent = middleLayer.getComponent('middleLayer');
middleLayerComponent.callMiddleLayerFunction(apiName, data, callback);
} else {
console.log('callMiddleLayerFunction: ' + apiName);
}
}
export function showTips(tips) {
const middleLayer = cc.find('middleLayer');
if (middleLayer) {
middleLayer.getComponent('middleLayer').showTips(tips);
if (middleLayerComponent.role == 'student') {
middleLayerComponent.onHomeworkFinish(() => { });
}
} else {
console.log(tips);
console.log('onHomeworkFinish');
}
}
}
\ No newline at end of file
{
"ver": "1.0.8",
"uuid": "ade7af40-d56d-4087-bbc6-2888fef55353",
"uuid": "4d413656-5e5b-4383-96bd-292370c1b448",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
......
{
"ver": "1.1.2",
"uuid": "8ba21262-178f-4fa5-afc9-2c1dd50ba3ab",
"uuid": "73f4732d-4c22-4edf-8879-b0737de06f1b",
"isBundle": false,
"bundleName": "",
"priority": 1,
......
This diff is collapsed.
......@@ -54,7 +54,7 @@ function execCmd(cmd, params, path) {
let creatorBasePath = 'CocosCreator';
if (process.platform !== 'win32') {
creatorBasePath = "/Applications/CocosCreator/Creator/2.4.5/CocosCreator.app/Contents/MacOS/CocosCreator";
creatorBasePath = "/Applications/Cocos/Creator/2.4.5/CocosCreator.app/Contents/MacOS/CocosCreator";
}
const buildCocos = function (args) {
return new Promise((resolve, reject) => {
......
This diff is collapsed.
This diff is collapsed.
......@@ -4,5 +4,6 @@
"name": "play",
"id": "9af72fd2-44a6-4131-8ea3-3e1b3fa22231",
"version": "2.4.5",
"isNew": false
"isNew": false,
"description": ""
}
\ No newline at end of file
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment