Commit 2a7dd682 authored by liujiangnan's avatar liujiangnan

feat: 初始化

parent 9f5f5457
No preview for this file type
......@@ -2,8 +2,6 @@
cocos creator技术框架下的H5互动模板框架脚手架,基于cocos creator实现快速开发基于绘玩云的H5互动课件。
[视频教程传送门](https://www.bilibili.com/video/BV1Dq4y1t7n5/)
# 使用简介
## 前期准备
......@@ -51,7 +49,21 @@ npm start
```
* 打开浏览器:http://staging-teach.ireadabc.com/template_ci/debug
* [点击查看调试视频教程](https://www.bilibili.com/video/BV1Dq4y1t7n5?p=8)
* 点击右上角齿轮,选择技术选型、调试模式选择“普通”
### 互动模板
* 找到项目根路径下 index.html 文件
* 在引入JS的位置将air.js改为air_online_open.js
* 启动本地服务
```
npm start
```
* 打开浏览器:http://staging-teach.ireadabc.com/template_ci/debug
* 点击右上角齿轮,选择技术选型、调试模式选择“互动”
* 左侧老师、右侧学生
### 真机调试
......@@ -69,11 +81,4 @@ npm start
* 手机和电脑连接同一个Wifi
* 打开调试app,根据提示输入IP地址,点击开始就可以在手机上预览模板了
* 使用 console.log("==调试信息=="); 可以打印日志进行必要的调试
* 点击左上角 “logcat” 可以查看运行日志,(logcat是可以按住拖动的, 所以不用考虑UI遮挡问题)
### 注意事项及常见问题
* 项目里所有文件及文件夹的命名方式要注意不能包含空格、汉字、减号
* 项目里尽量不要使用setTimeout、setInterval等定时器,如果使用了记得在onDestroy中释放掉(onDestroy 是指CocosCreator的生命周期钩子)
* 理论上禁止使用全局变量,因为模板到线上会进行组装,常见问题是一个模板使用多次造成全局变量被读脏
* 使用 this.log("==调试信息=="); 可以打印日志进行必要的调试
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "f0680ae0-c079-45ef-abd7-9e63d90b982b",
"downloadMode": 0,
"duration": 0.130612,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.0",
"uuid": "c551970e-b095-45f3-9f1d-25cde8b8deb1",
"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() {
}
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.loadAny(preloadArr, null, null, (err, data) => {
if (window && window["air"]) {
// window["air"].onCourseInScreen = (next) => {
// window["air"].isCourseInScreen = true;
// this.onLoadEnd();
// next();
// };
this.onLoadEnd();
window["air"].hideAirClassLoading();
} else {
this.onLoadEnd();
}
cc.debug.setDisplayStats(false);
});
}
log (str) {
const node = cc.find('middleLayer');
if(node){
node.getComponent('middleLayer').log(str);
}else{
cc.log(str);
}
}
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
{
"ver": "2.3.5",
"uuid": "18d07592-51a9-421e-8972-0f67b68d29e1",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 144,
"height": 144,
"platformSettings": {},
"subMetas": {
"icon": {
"ver": "1.0.4",
"uuid": "6fbc30a8-3c49-44ae-8ba4-7f56f385b78a",
"rawTextureUuid": "18d07592-51a9-421e-8972-0f67b68d29e1",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": -0.5,
"trimX": 3,
"trimY": 2,
"width": 138,
"height": 141,
"rawWidth": 144,
"rawHeight": 144,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
......@@ -4,9 +4,18 @@
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"compressionType": {
"android": "default",
"ios": "default"
},
"optimizeHotUpdate": {
"android": false,
"ios": false
},
"inlineSpriteFrames": {
"android": false,
"ios": false
},
"isRemoteBundle": {
"ios": false,
"android": false
......
{
"ver": "1.1.2",
"uuid": "e0ae4184-41ff-46b0-9091-3eb0ce6568d1",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"__type__": "cc.AnimationClip",
"_name": "loading",
"_objFlags": 0,
"_native": "",
"_duration": 0.38333333333333336,
"sample": 60,
"speed": 0.5,
"wrapMode": 2,
"curveData": {
"comps": {
"cc.Sprite": {
"spriteFrame": [
{
"frame": 0,
"value": {
"__uuid__": "d483699c-1f3a-44ed-880f-c0289a7e142b"
}
},
{
"frame": 0.016666666666666666,
"value": {
"__uuid__": "50d4caeb-d718-4b0e-be1b-09d670123a65"
}
},
{
"frame": 0.03333333333333333,
"value": {
"__uuid__": "07928de5-691d-4237-b28f-5fbe88dbaff8"
}
},
{
"frame": 0.05,
"value": {
"__uuid__": "426b4bd1-e569-4809-9a34-83fb850983c7"
}
},
{
"frame": 0.06666666666666667,
"value": {
"__uuid__": "1f2d2a0e-761a-46a3-89a9-63546a6f7f8e"
}
},
{
"frame": 0.08333333333333333,
"value": {
"__uuid__": "c26ed7a7-8ed8-4143-96f9-e7194b5499b2"
}
},
{
"frame": 0.1,
"value": {
"__uuid__": "df7d1fce-986a-4791-b1a2-70581e127a4d"
}
},
{
"frame": 0.11666666666666667,
"value": {
"__uuid__": "af31cfc5-ffae-4430-9532-4715ad337e31"
}
},
{
"frame": 0.13333333333333333,
"value": {
"__uuid__": "890b9af8-cab4-4bbe-924e-ee0953dc3ca2"
}
},
{
"frame": 0.15,
"value": {
"__uuid__": "f9c5bce9-2c56-4536-8ef8-f16dcb3a052a"
}
},
{
"frame": 0.16666666666666666,
"value": {
"__uuid__": "c526144e-cbe9-4cac-a018-17bf035ebdc3"
}
},
{
"frame": 0.18333333333333332,
"value": {
"__uuid__": "e6c3a7d4-4820-4600-b555-c38e80f2b342"
}
},
{
"frame": 0.2,
"value": {
"__uuid__": "d483699c-1f3a-44ed-880f-c0289a7e142b"
}
},
{
"frame": 0.21666666666666667,
"value": {
"__uuid__": "c036d7e2-f4de-4260-93ee-7fdfca93c989"
}
},
{
"frame": 0.23333333333333334,
"value": {
"__uuid__": "1cc11112-e06b-4dbe-ae93-81bf7a9422c5"
}
},
{
"frame": 0.25,
"value": {
"__uuid__": "79da537a-7da1-4dba-a374-ff933a0f74c6"
}
},
{
"frame": 0.26666666666666666,
"value": {
"__uuid__": "054c9698-ef26-4a77-b7ff-83600000578e"
}
},
{
"frame": 0.2833333333333333,
"value": {
"__uuid__": "9eca02a2-376a-47a9-bf7a-80caf034d613"
}
},
{
"frame": 0.3,
"value": {
"__uuid__": "b84f5102-3a81-4e49-8784-077365b321c1"
}
},
{
"frame": 0.31666666666666665,
"value": {
"__uuid__": "5207aaf3-3a46-402f-a44f-80030fd660d9"
}
},
{
"frame": 0.3333333333333333,
"value": {
"__uuid__": "86e22060-8ef8-49fa-95d5-08906708bedd"
}
},
{
"frame": 0.35,
"value": {
"__uuid__": "8c5c16ce-0683-467d-a4b4-c8994310cc62"
}
},
{
"frame": 0.36666666666666664,
"value": {
"__uuid__": "de1f4f72-41a8-4104-8a5c-bf5b4eb4e0fa"
}
}
]
}
}
},
"events": []
}
\ No newline at end of file
{
"ver": "2.1.0",
"uuid": "c01fcefa-a80e-43a2-8b03-cce500eba63d",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "ac7e840c-596c-4d10-80e2-8c44f3cce9b7",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "2a589e55-1cf1-411b-9db0-95a119f58151",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 356,
"height": 356,
"platformSettings": {},
"subMetas": {
"icon_01": {
"ver": "1.0.4",
"uuid": "d483699c-1f3a-44ed-880f-c0289a7e142b",
"rawTextureUuid": "2a589e55-1cf1-411b-9db0-95a119f58151",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -11.5,
"offsetY": 4,
"trimX": 36,
"trimY": 15,
"width": 261,
"height": 318,
"rawWidth": 356,
"rawHeight": 356,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "7399861a-591c-4460-a1e6-b39a7d4de39e",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 356,
"height": 356,
"platformSettings": {},
"subMetas": {
"icon_02": {
"ver": "1.0.4",
"uuid": "50d4caeb-d718-4b0e-be1b-09d670123a65",
"rawTextureUuid": "7399861a-591c-4460-a1e6-b39a7d4de39e",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -2.5,
"offsetY": -2,
"trimX": 38,
"trimY": 18,
"width": 275,
"height": 324,
"rawWidth": 356,
"rawHeight": 356,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "f3cd036c-3597-4139-a257-27a4a68dd720",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 357,
"height": 356,
"platformSettings": {},
"subMetas": {
"icon_03": {
"ver": "1.0.4",
"uuid": "07928de5-691d-4237-b28f-5fbe88dbaff8",
"rawTextureUuid": "f3cd036c-3597-4139-a257-27a4a68dd720",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 3.5,
"offsetY": -6,
"trimX": 40,
"trimY": 21,
"width": 284,
"height": 326,
"rawWidth": 357,
"rawHeight": 356,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "e48c9f43-a07c-4b36-8e8b-95ccdf7c9024",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 356,
"height": 356,
"platformSettings": {},
"subMetas": {
"icon_04": {
"ver": "1.0.4",
"uuid": "426b4bd1-e569-4809-9a34-83fb850983c7",
"rawTextureUuid": "e48c9f43-a07c-4b36-8e8b-95ccdf7c9024",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 6.5,
"offsetY": -12,
"trimX": 42,
"trimY": 25,
"width": 285,
"height": 330,
"rawWidth": 356,
"rawHeight": 356,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "d3387ee0-2f1b-42b6-babd-75fcfbb501f8",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 356,
"height": 356,
"platformSettings": {},
"subMetas": {
"icon_05": {
"ver": "1.0.4",
"uuid": "1f2d2a0e-761a-46a3-89a9-63546a6f7f8e",
"rawTextureUuid": "d3387ee0-2f1b-42b6-babd-75fcfbb501f8",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 5,
"offsetY": -12,
"trimX": 42,
"trimY": 25,
"width": 282,
"height": 330,
"rawWidth": 356,
"rawHeight": 356,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "65b3e1d5-b7d8-48c4-9f1c-0a658b3ecef1",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 356,
"height": 356,
"platformSettings": {},
"subMetas": {
"icon_06": {
"ver": "1.0.4",
"uuid": "c26ed7a7-8ed8-4143-96f9-e7194b5499b2",
"rawTextureUuid": "65b3e1d5-b7d8-48c4-9f1c-0a658b3ecef1",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 5,
"offsetY": -12,
"trimX": 42,
"trimY": 25,
"width": 282,
"height": 330,
"rawWidth": 356,
"rawHeight": 356,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "c169436c-47d7-4237-bcf0-b876328e3a19",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 356,
"height": 356,
"platformSettings": {},
"subMetas": {
"icon_07": {
"ver": "1.0.4",
"uuid": "df7d1fce-986a-4791-b1a2-70581e127a4d",
"rawTextureUuid": "c169436c-47d7-4237-bcf0-b876328e3a19",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 5,
"offsetY": -12.5,
"trimX": 42,
"trimY": 26,
"width": 282,
"height": 329,
"rawWidth": 356,
"rawHeight": 356,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "e50e20f4-eba6-476d-96b4-a4982a02d57c",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 356,
"height": 356,
"platformSettings": {},
"subMetas": {
"icon_08": {
"ver": "1.0.4",
"uuid": "af31cfc5-ffae-4430-9532-4715ad337e31",
"rawTextureUuid": "e50e20f4-eba6-476d-96b4-a4982a02d57c",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -9,
"offsetY": -8.5,
"trimX": 39,
"trimY": 18,
"width": 260,
"height": 337,
"rawWidth": 356,
"rawHeight": 356,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "ac63517b-96bc-42a8-8494-6f2a11530d98",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 357,
"height": 356,
"platformSettings": {},
"subMetas": {
"icon_09": {
"ver": "1.0.4",
"uuid": "890b9af8-cab4-4bbe-924e-ee0953dc3ca2",
"rawTextureUuid": "ac63517b-96bc-42a8-8494-6f2a11530d98",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -9,
"offsetY": -8,
"trimX": 39,
"trimY": 17,
"width": 261,
"height": 338,
"rawWidth": 357,
"rawHeight": 356,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "0e53c38c-bbb8-494d-b060-83b81c2705d8",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 356,
"height": 356,
"platformSettings": {},
"subMetas": {
"icon_10": {
"ver": "1.0.4",
"uuid": "f9c5bce9-2c56-4536-8ef8-f16dcb3a052a",
"rawTextureUuid": "0e53c38c-bbb8-494d-b060-83b81c2705d8",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -9.5,
"offsetY": -8,
"trimX": 38,
"trimY": 17,
"width": 261,
"height": 338,
"rawWidth": 356,
"rawHeight": 356,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "1bcbafa4-1742-4a84-a1c9-8c5a8f7e0071",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 356,
"height": 356,
"platformSettings": {},
"subMetas": {
"icon_11": {
"ver": "1.0.4",
"uuid": "c526144e-cbe9-4cac-a018-17bf035ebdc3",
"rawTextureUuid": "1bcbafa4-1742-4a84-a1c9-8c5a8f7e0071",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -13,
"offsetY": 9.5,
"trimX": 37,
"trimY": 15,
"width": 256,
"height": 307,
"rawWidth": 356,
"rawHeight": 356,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "955d2b2a-5526-482b-9113-cab7fdda8609",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 356,
"height": 356,
"platformSettings": {},
"subMetas": {
"icon_12": {
"ver": "1.0.4",
"uuid": "e6c3a7d4-4820-4600-b555-c38e80f2b342",
"rawTextureUuid": "955d2b2a-5526-482b-9113-cab7fdda8609",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -12.5,
"offsetY": 10.5,
"trimX": 38,
"trimY": 14,
"width": 255,
"height": 307,
"rawWidth": 356,
"rawHeight": 356,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "da0bd795-8f86-457a-b323-3eb4019116aa",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 356,
"height": 356,
"platformSettings": {},
"subMetas": {
"icon_13": {
"ver": "1.0.4",
"uuid": "d33f9cb8-3b2f-41c9-9a9e-71220fe37f4f",
"rawTextureUuid": "da0bd795-8f86-457a-b323-3eb4019116aa",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -12.5,
"offsetY": 10,
"trimX": 38,
"trimY": 14,
"width": 255,
"height": 308,
"rawWidth": 356,
"rawHeight": 356,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "ed158124-21b0-4f02-af8a-f7e9c5f239ad",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 356,
"height": 356,
"platformSettings": {},
"subMetas": {
"icon_14": {
"ver": "1.0.4",
"uuid": "c036d7e2-f4de-4260-93ee-7fdfca93c989",
"rawTextureUuid": "ed158124-21b0-4f02-af8a-f7e9c5f239ad",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -8.5,
"offsetY": -8.5,
"trimX": 41,
"trimY": 19,
"width": 257,
"height": 335,
"rawWidth": 356,
"rawHeight": 356,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "967a032b-a532-4564-a3db-7572277e2773",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 357,
"height": 356,
"platformSettings": {},
"subMetas": {
"icon_15": {
"ver": "1.0.4",
"uuid": "1cc11112-e06b-4dbe-ae93-81bf7a9422c5",
"rawTextureUuid": "967a032b-a532-4564-a3db-7572277e2773",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -9,
"offsetY": -8.5,
"trimX": 41,
"trimY": 19,
"width": 257,
"height": 335,
"rawWidth": 357,
"rawHeight": 356,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "79854d15-8f61-457c-9887-a2b3b5a8f029",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 356,
"height": 356,
"platformSettings": {},
"subMetas": {
"icon_16": {
"ver": "1.0.4",
"uuid": "79da537a-7da1-4dba-a374-ff933a0f74c6",
"rawTextureUuid": "79854d15-8f61-457c-9887-a2b3b5a8f029",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -9.5,
"offsetY": -9,
"trimX": 40,
"trimY": 19,
"width": 257,
"height": 336,
"rawWidth": 356,
"rawHeight": 356,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "d26be600-855a-494c-9fea-461fafdb9b8e",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 356,
"height": 356,
"platformSettings": {},
"subMetas": {
"icon_17": {
"ver": "1.0.4",
"uuid": "054c9698-ef26-4a77-b7ff-83600000578e",
"rawTextureUuid": "d26be600-855a-494c-9fea-461fafdb9b8e",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -7,
"offsetY": -11.5,
"trimX": 45,
"trimY": 23,
"width": 252,
"height": 333,
"rawWidth": 356,
"rawHeight": 356,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "ef3afd13-cf90-49bd-8a75-e957e61c6edf",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 356,
"height": 356,
"platformSettings": {},
"subMetas": {
"icon_18": {
"ver": "1.0.4",
"uuid": "9eca02a2-376a-47a9-bf7a-80caf034d613",
"rawTextureUuid": "ef3afd13-cf90-49bd-8a75-e957e61c6edf",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -7,
"offsetY": -11.5,
"trimX": 45,
"trimY": 23,
"width": 252,
"height": 333,
"rawWidth": 356,
"rawHeight": 356,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "224cdc7d-10fe-4335-ad22-95feb80db21f",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 356,
"height": 356,
"platformSettings": {},
"subMetas": {
"icon_19": {
"ver": "1.0.4",
"uuid": "b84f5102-3a81-4e49-8784-077365b321c1",
"rawTextureUuid": "224cdc7d-10fe-4335-ad22-95feb80db21f",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -7,
"offsetY": -11,
"trimX": 45,
"trimY": 23,
"width": 252,
"height": 332,
"rawWidth": 356,
"rawHeight": 356,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "0d80bf10-b20d-43e7-9e15-cd07e79a4c77",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 356,
"height": 356,
"platformSettings": {},
"subMetas": {
"icon_20": {
"ver": "1.0.4",
"uuid": "5207aaf3-3a46-402f-a44f-80030fd660d9",
"rawTextureUuid": "0d80bf10-b20d-43e7-9e15-cd07e79a4c77",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -6,
"offsetY": -5.5,
"trimX": 39,
"trimY": 19,
"width": 266,
"height": 329,
"rawWidth": 356,
"rawHeight": 356,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "4181f3d2-2f71-4416-b582-51d861f22b3b",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 357,
"height": 356,
"platformSettings": {},
"subMetas": {
"icon_21": {
"ver": "1.0.4",
"uuid": "86e22060-8ef8-49fa-95d5-08906708bedd",
"rawTextureUuid": "4181f3d2-2f71-4416-b582-51d861f22b3b",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -6.5,
"offsetY": -5.5,
"trimX": 39,
"trimY": 19,
"width": 266,
"height": 329,
"rawWidth": 357,
"rawHeight": 356,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "6313183c-883b-4ea1-bc7d-95fbc723299d",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 356,
"height": 356,
"platformSettings": {},
"subMetas": {
"icon_22": {
"ver": "1.0.4",
"uuid": "8c5c16ce-0683-467d-a4b4-c8994310cc62",
"rawTextureUuid": "6313183c-883b-4ea1-bc7d-95fbc723299d",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -12.5,
"offsetY": 8,
"trimX": 37,
"trimY": 12,
"width": 257,
"height": 316,
"rawWidth": 356,
"rawHeight": 356,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "e226e1b7-f728-4e65-ace8-6e52102d9809",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 356,
"height": 356,
"platformSettings": {},
"subMetas": {
"icon_23": {
"ver": "1.0.4",
"uuid": "de1f4f72-41a8-4104-8a5c-bf5b4eb4e0fa",
"rawTextureUuid": "e226e1b7-f728-4e65-ace8-6e52102d9809",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -12,
"offsetY": 4,
"trimX": 36,
"trimY": 15,
"width": 260,
"height": 318,
"rawWidth": 356,
"rawHeight": 356,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "197cb28b-4ee4-4399-ae88-7cf915fefcc1",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "8315ed0e-dbc2-4825-8b02-09453744cd01",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
// Learn cc.Class:
// - https://docs.cocos.com/creator/manual/en/scripting/class.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
cc.Class({
extends: cc.Component,
properties: {
// foo: {
// // ATTRIBUTES:
// default: null, // The default value will be used only when the component attaching
// // to a node for the first time
// type: cc.SpriteFrame, // optional, default is typeof default
// serializable: true, // optional, default is true
// },
// bar: {
// type: cc.Node,
// get () {
// return this._bar;
// },
// set (value) {
// this._bar = value;
// }
// },
},
// LIFE-CYCLE CALLBACKS:
// onLoad () {},
start () {
this.init();
},
barBaseW: null,
barSpr: null,
barSf: null,
init() {
this.bar = cc.find('bar', this.node);
// this.bar.x = (this.node.width - this.bar.width) / 2;
// console.log('this.bar.x: ', this.bar.x);
this.barBaseW = this.bar.width;
this.barSpr = this.bar.getComponent(cc.Sprite);
this.barSf = this.barSpr.spriteFrame;
this.setProgress(0);
},
setProgress(progress) {
setTimeout(() => {
if (!this.barSf) {
return;
}
const w = this.barBaseW * progress;
const rect = this.barSf.getRect();
rect.width = w;
this.bar.width = w;
this.barSpr.spriteFrame.setRect(rect);
}, 1);
},
// update (dt) {},
});
{
"ver": "1.0.8",
"uuid": "f8b451ff-857c-4ca8-9870-866bc5154a29",
"uuid": "ff03bff6-e911-4b26-8e28-803cdc16c50f",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
......
[
{
"__type__": "cc.Prefab",
"_name": "",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"asyncLoadAssets": false,
"readonly": false
},
{
"__type__": "cc.Node",
"_name": "progress",
"_objFlags": 0,
"_parent": null,
"_children": [
{
"__id__": 2
}
],
"_active": true,
"_components": [
{
"__id__": 5
},
{
"__id__": 6
}
],
"_prefab": {
"__id__": 7
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 269,
"height": 16
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0,
"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": "bar",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_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": 269,
"height": 16
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0,
"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__": "c43f093f-a7c5-42d5-bf56-778a3548a7c3"
},
"_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": {
"__id__": 0
},
"fileId": "7dOjkMYWpFQaM6/QbKkBy/",
"sync": false
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "82ee3fa0-26e3-43e8-afca-8bbc978d88e4"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "ff03b/26RFLJo4ogDzcFsUP",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "",
"sync": false
}
]
\ No newline at end of file
{
"ver": "1.2.9",
"uuid": "3d356c4d-cb23-4239-aa5f-8a913f420fa4",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "bbf334e3-49af-4d0b-9d4c-a7a9398f1261",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "344dc346-7299-44ae-8693-0ac57ec21aca",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 269,
"height": 16,
"platformSettings": {},
"subMetas": {
"record_progress_bar": {
"ver": "1.0.4",
"uuid": "c43f093f-a7c5-42d5-bf56-778a3548a7c3",
"rawTextureUuid": "344dc346-7299-44ae-8693-0ac57ec21aca",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 269,
"height": 16,
"rawWidth": 269,
"rawHeight": 16,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "cb4c174a-628f-41b0-b661-f98961162196",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 269,
"height": 16,
"platformSettings": {},
"subMetas": {
"record_progress_bg": {
"ver": "1.0.4",
"uuid": "82ee3fa0-26e3-43e8-afca-8bbc978d88e4",
"rawTextureUuid": "cb4c174a-628f-41b0-b661-f98961162196",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 269,
"height": 16,
"rawWidth": 269,
"rawHeight": 16,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "1.2.9",
"uuid": "0737ce42-24f0-45c6-8e1a-8bdab4f74ba3",
"uuid": "f2080b9e-65f4-4a10-b460-eb81064a9d76",
"asyncLoadAssets": false,
"autoReleaseAssets": true,
"subMetas": {}
......
// Learn cc.Class:
// - https://docs.cocos.com/creator/manual/en/scripting/class.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
cc.Class({
extends: cc.Component,
properties: {
// foo: {
// // ATTRIBUTES:
// default: null, // The default value will be used only when the component attaching
// // to a node for the first time
// type: cc.SpriteFrame, // optional, default is typeof default
// serializable: true, // optional, default is true
// },
// bar: {
// get () {
// return this._bar;
// },
// set (value) {
// this._bar = value;
// }
// },
},
// LIFE-CYCLE CALLBACKS:
// onLoad () {},
start () {
},
// update (dt) {},
});
{
"ver": "1.0.8",
"uuid": "408a67f8-65fa-4cf1-8cf2-83e20e1a0fd5",
"uuid": "551771f1-7b43-4157-bb84-cdbb730dcddd",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
......
This diff is collapsed.
{
"ver": "1.0.8",
"uuid": "5db4ac00-dc44-44aa-a996-19aefa0955c5",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
import { middleLayerBase } from "./middleLayerBase";
import { initAir } from './air';
const { ccclass, property } = cc._decorator;
@ccclass
export default class NewClass extends middleLayerBase {
showMask() {
const mask = cc.find('middleLayer/mask');
mask.active = true;
cc.tween(mask)
.set({ opacity: 0 })
.to(0.5, { opacity: 0 })
.start();
}
hideMask() {
const mask = cc.find('middleLayer/mask');
mask.stopAllActions();
cc.tween(mask)
.set({ opacity: 0 })
.to(0.5, { opacity: 0 })
.call(() => {
mask.active = false;
})
.start();
}
// 需要预加载的数量
preloadCount = null;
// 统计已加载的数量
loadedCount = null;
role;
// 统一释放异步资源的方法
onLoad() {
this.preloadCount = 0;
this.loadedCount = 0;
initAir(this);
this.reWriteAir();
// this.preloadAll();
this.role = 'student';
}
start() {
this.node.zIndex = 9999;
cc.game.addPersistRootNode(this.node);
global.middleLayer = cc.find('middleLayer').getComponent('middleLayer');
this.loadOnlineCourseWare(23075);
}
preloadAll() {
if ((<any>window).preloadBundleAndSourcesFlag) {
// 只加载一次就行了
return;
}
(<any>window).preloadBundleAndSourcesFlag = true;
cc.find("middleLayer/ui/ProgressLabel").active = true;
cc.find('middleLayer/ui/loadingProgress').active = true;
let platform = "web_desktop";
if (cc.sys.os == cc.sys.OS_IOS) {
platform = "ios";
} else if (cc.sys.os == cc.sys.OS_ANDROID) {
platform = "android";
}
this.callNetworkApiGet(`/api/syllabus/v1/allbundles`, { orgid: 483, platform }, (datastr) => {
const data = JSON.parse(datastr);
if (data.rows && data.rows.length > 0) {
this.preloadCount += data.rows.length;
}
this.callNetworkApiGet(`/api/syllabus/v1/allresources`, { orgid: 483 }, (datastr1) => {
const data1 = JSON.parse(datastr1);
if (data1.rows && data1.rows.length > 0) {
this.preloadCount += data1.rows.length;
}
console.log('data.rows = ' + JSON.stringify(data.rows));
this.batchPreloadScene(data.rows);
this.preloadSource(data1.rows);
});
});
}
// 测试用
preloadSourceImman() {
cc.find("middleLayer/ui/ProgressLabel").active = true;
cc.find('middleLayer/ui/loadingProgress').active = true;
this.callNetworkApiGet(`/api/courseware/v1/getresources`, { courseid: 20894 }, (datastr1) => {
const data1 = JSON.parse(datastr1);
if (data1.rows && data1.rows.length > 0) {
this.preloadCount += data1.rows.length;
}
this.log('data1.rows = ' + JSON.stringify(data1.rows));
this.preloadSource(data1.rows);
});
}
batchPreloadScene(scenes = []) {
const expects = [
// 'op_03_2',
// 'OP10_online',
];
const _this = this;
let i = 0;
const load = function () {
const scene = scenes[i];
if (expects.includes(scene.sceneName)) {
_this.loadedCount++;
_this.updateProcessBar();
i++;
if (i < scenes.length) {
setTimeout(() => {
load();
}, 1);
}
return;
}
cc.assetManager.loadBundle(scene.bondleUrl, { version: scene.version }, (err, bundle) => {
console.log(`${scene.bondleUrl}---场景开始loadBundle----`);
if (!bundle) {
_this.loadedCount++;
_this.updateProcessBar();
i++;
if (i < scenes.length) {
setTimeout(() => {
load();
}, 1);
}
return;
}
bundle.preloadScene(scene.sceneName, () => { }, () => {
console.log(`${scene.sceneName}场景预加载结束`);
_this.loadedCount++;
_this.updateProcessBar();
i++;
if (i < scenes.length) {
setTimeout(() => {
load();
}, 1);
}
});
});
}
if (scenes && scenes.length > 0) {
load();
}
}
preloadSource(array) {
const rows = array || [];
const batchLoad = () => {
let tempArr = rows.splice(0, 10);
let len = tempArr.length;
for (let i = 0; i < tempArr.length; i++) {
cc.assetManager.loadRemote(tempArr[i], (err, texture) => {
if (err) {
console.log(err)
}
this.loadedCount++;
this.updateProcessBar();
if (i === len - 1) {
batchLoad();
}
});
}
}
batchLoad();
}
updateProcessBar() {
const label = cc.find("middleLayer/ui/ProgressLabel").getComponent(cc.Label);
const loadingProgress = cc.find('middleLayer/ui/loadingProgress');
label.string = `正在加载:${this.loadedCount} / ${this.preloadCount}`;
if (this.loadedCount > this.preloadCount * 0.99) {
cc.find("middleLayer/ui/ProgressLabel").active = false;
loadingProgress.active = false;
this.log("资源全部加载完成");
}
loadingProgress.getComponent(cc.ProgressBar).progress = this.loadedCount / this.preloadCount;
}
onHomeworkFinish(callBack, data = null) {
this.goNextPage();
}
localMode = false;
asyncDelayLog(str) {
console.log(str);
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve(null);
}, 1);
});
}
initListener() {
}
log(str) {
console.log(str);
}
reWriteAir() {
(<any>window).courseware.getData = (callback) => {
let data = null;
if (this.courseItem && this.courseItem.data) {
data = JSON.parse(this.courseItem.data);
}
this.log("===成功调用getData===" + JSON.stringify(data));
callback && callback(data);
}
(<any>window).courseware.nextPage = () => {
this.goNextPage();
}
(<any>window).courseware.beforePage = () => {
this.goPrePage();
}
(<any>window).courseware.sendAnswer = (answerObj) => {
this.log("===成功调用sendAnswer===" + JSON.stringify(answerObj));
this.callNetworkApiPost(`/api/oxford/courseware/v1/${this.courseItem.id}/saveanswer`, answerObj, (data) => {
answerObj.callback && answerObj.callback(JSON.stringify(data.row));
});
}
(<any>window).courseware.getAnswer = (queryObj, callback) => {
this.log("===成功调用getAnswer===" + JSON.stringify(queryObj));
this.callNetworkApiGet(`/api/oxford/courseware/v1/${this.courseItem.id}/getanswer`, queryObj, (datastr) => {
const data = JSON.parse(datastr);
callback && callback(JSON.stringify(data.rows));
});
}
}
callNativeFunction(param) {
const paramStr = JSON.stringify(param);
if (cc.sys.isNative && cc.sys.os == cc.sys.OS_IOS) {
return jsb.reflection.callStaticMethod('CocosMng', 'cocosWithNativeProtocol:', paramStr);
} else if (cc.sys.isNative && cc.sys.os == cc.sys.OS_ANDROID) {
return jsb.reflection.callStaticMethod('com/iplayabc/cocos/AppActivity', 'cocosWithNativeProtocol', '(Ljava/lang/String;)Ljava/lang/String;', paramStr);
} else if (cc.sys.isNative && cc.sys.os == cc.sys.OS_WINDOWS) {
console.log('汪汪汪')
} else {
console.error('非源生环境11');
}
}
isShowWaiting = false;
showWaitingLetters() {
if (this.isShowWaiting) {
return;
}
this.isShowWaiting = true;
const layout = cc.find('middleLayer/layout');
layout.removeAllChildren();
const canvas = cc.find("Canvas");
const bg = layout.addComponent(cc.Graphics);
bg.fillRect(-canvas.width / 2, -canvas.height / 2, canvas.width, canvas.height);
const laodingLayer = cc.find('middleLayer/loadingLayer');
laodingLayer.active = true;
const script = cc.find('middleLayer/loadingLayer/progress').getComponent('progressScript');
script.setProgress(0);
const id = setInterval(() => {
// console.log('changeObj.value: ', changeObj.value);
script.setProgress(changeObj.value);
}, 1);
const changeObj = { value: 0 };
cc.tween(changeObj)
.to(5, { value: 0.9 })
.call(() => {
clearInterval(id);
})
.start();
}
hideWaitingLetters() {
const layout = cc.find('middleLayer/layout');
layout.active = false;
const laodingLayer = cc.find('middleLayer/loadingLayer');
laodingLayer.active = false;
}
getRainbowColorList() {
return [
cc.color(255, 255, 0),
cc.color(128, 255, 0),
cc.color(0, 255, 0),
cc.color(0, 0, 0),
cc.color(0, 255, 128),
cc.color(0, 255, 255),
cc.color(0, 128, 255),
cc.color(0, 0, 255),
cc.color(128, 0, 255),
cc.color(255, 0, 255),
cc.color(255, 0, 128),
cc.color(255, 0, 0),
cc.color(255, 128, 0),
cc.color(255, 255, 0),
];
}
}
{
"ver": "1.0.8",
"uuid": "60d81384-fa74-4bb6-832e-9012d6659bb6",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
export abstract class middleLayerBase extends cc.Component {
abstract reWriteAir(): void;
abstract showMask(): void;
abstract hideMask(): void;
abstract hideWaitingLetters(): void;
abstract showWaitingLetters(): void;
callNetworkApiPost(uri, data, callBack) {
this.getBaseUrl((baseUrl) => {
const xhr = new XMLHttpRequest();
const url = `${baseUrl}${uri}`;
xhr.open("POST", url, true);
xhr.setRequestHeader('content-type', 'application/json');
xhr.onreadystatechange = () => {
if (xhr.readyState == 4) {
callBack(JSON.parse(xhr.responseText));
}
}
xhr.send(JSON.stringify(data));
});
}
callNetworkApiGet(uri, data, callBack) {
this.getBaseUrl((baseUrl) => {
let queryStr = '?';
const params = [];
for (const key in data) {
if (Object.hasOwnProperty.call(data, key)) {
params.push(`${key}=${data[key]}`);
}
}
queryStr += params.join("&");
const xhr = new XMLHttpRequest();
xhr.onreadystatechange = () => {
if (xhr.readyState == 4 && (xhr.status >= 200 && xhr.status < 400)) {
callBack(xhr.responseText);
}
};
const url = `${baseUrl}${uri}${queryStr}`;
console.log('url = ' + url);
xhr.open('GET', url, true);
xhr.send();
});
}
async getBaseUrl(callback) {
const engineInfo = await this.getEngineInfo();
const { isDev } = JSON.parse(engineInfo);
if (isDev == 1) {
callback('http://staging-openapi.iteachabc.com');
} else {
callback('http://openapi.iteachabc.com');
}
}
getEngineInfo() {
if ((<any>window).air.engineInfo) {
return (<any>window).air.engineInfo;
} else {
return new Promise((resolve, reject) => {
(<any>window).courseware.getEngineInfo(() => {
resolve((<any>window).air.engineInfo);
});
});
}
}
asyncCallNetworkApiGet(apiName, data) {
return new Promise((resolve, reject) => {
this.callNetworkApiGet(apiName, data, (res => {
resolve(res);
}));
});
}
asyncCallNetworkApiPost(uri, data) {
return new Promise((resolve, reject) => {
this.callNetworkApiPost(uri, data, (res) => {
resolve(res);
});
});
}
loadOnlineBundle(bundleName) {
this.callNetworkApiGet(`/api/template/v1/${bundleName}`, {}, (datastr) => {
const data = JSON.parse(datastr);
let configData = null;
if (cc.sys.os == cc.sys.OS_IOS) {
configData = data.data.conf.ios;
} else if (cc.sys.os == cc.sys.OS_ANDROID) {
configData = data.data.conf.android;
} else {
configData = data.data.conf.web_desktop;
}
const sceneName = configData.sceneName;
const version = configData.version;
const bondleUrl = configData.bondleUrl;
this.loadBundle(sceneName, version, bondleUrl);
});
}
currentBundleInfo = null;
reloadBundle() {
const { sceneName, version, bondleUrl } = this.currentBundleInfo;
this.loadBundle(sceneName, version, bondleUrl);
}
async loadBundle(sceneName, version, bondleUrl) {
this.currentBundleInfo = { sceneName, version, bondleUrl };
this.showMask();
this.showWaitingLetters();
const oldSceneName = this.currentBundleInfo?.sceneName;
const engineInfo = await this.getEngineInfo();
const { isChanged } = JSON.parse(engineInfo);
if (isChanged) {
await this.checkRotateScreen(oldSceneName, sceneName);
}
cc.assetManager.loadBundle(bondleUrl, { version: version }, async (err, bundle) => {
bundle.loadScene(sceneName, null, null, (err, scene) => {
cc.audioEngine.stopAll();
cc.director.runScene(scene, null, () => {
console.log('sceneName = ' + sceneName);
const canvas = cc.find('Canvas');
const middleLayer = cc.find('middleLayer');
this.hideWaitingLetters();
this.hideMask();
canvas.getComponent(cc.Widget).updateAlignment();
middleLayer.scale = canvas.width / middleLayer.width;
// this.showLog('middleLayer.scale = ' + middleLayer.scale);
});
});
});
}
checkRotateScreen(oldSceneName: string, newSceneName: string) {
const sceneNameList = ['op_16'];
if (sceneNameList.includes(oldSceneName) || sceneNameList.includes(newSceneName)) {
return new Promise((resolve, reject) => {
if (sceneNameList.includes(newSceneName)) {
// 如果已经是竖屏了
if (cc.view.getCanvasSize().width < cc.view.getCanvasSize().height) {
resolve(null);
return;
}
// 旋转到竖屏
(<any>window).courseware.onConfigurationPortrait({}, async () => {
while (cc.view.getCanvasSize().width > cc.view.getCanvasSize().height) {
await asyncDelay(0.1);
}
resolve(null);
});
} else {
// 如果已经是横屏了
if (cc.view.getCanvasSize().width > cc.view.getCanvasSize().height) {
resolve(null);
return;
}
// 旋转到横屏
(<any>window).courseware.onConfigurationLandscape({}, async () => {
while (cc.view.getCanvasSize().width < cc.view.getCanvasSize().height) {
await asyncDelay(0.1);
}
resolve(null);
});
}
});
}
}
courses = null;
courseIndex = 0;
courseItem = null;
loadOnlineCourseWare(courseId, linkFlag = false) {
this.showWaitingLetters();
let api = `/api/courseware/v1/${courseId}/list`;
if (linkFlag === true) {
api = `/api/courseware/v1/${courseId}/eq/level/list`;
}
this.callNetworkApiGet(api, {}, (datastr) => {
const data = JSON.parse(datastr);
if (data.rows && data.rows.length > 0) {
this.courses = data.rows;
this.courseIndex = data.index || 0;
this.courseItem = data.rows[this.courseIndex];
}
if (this.courses && this.courses.length > 1 && this.courseIndex <= this.courses.length - 1) {
}
if (this.courseIndex > 0) {
}
this.reWriteAir();
this.loadPageBundle();
});
}
loadPageBundle() {
let sceneName, version, bondleUrl = "";
if (cc.sys.os == cc.sys.OS_IOS) {
sceneName = this.courseItem.conf.ios.sceneName;
version = this.courseItem.conf.ios.version;
bondleUrl = this.courseItem.conf.ios.bondleUrl;
} else if (cc.sys.os == cc.sys.OS_ANDROID) {
sceneName = this.courseItem.conf.android.sceneName;
version = this.courseItem.conf.android.version;
bondleUrl = this.courseItem.conf.android.bondleUrl;
} else {
sceneName = this.courseItem.conf.web_desktop.sceneName;
version = this.courseItem.conf.web_desktop.version;
bondleUrl = this.courseItem.conf.web_desktop.bondleUrl;
}
this.loadBundle(sceneName, version, bondleUrl);
}
goPrePage() {
this.goTarIndexPage(this.courseIndex - 1);
}
goNextPage() {
this.goTarIndexPage(this.courseIndex + 1);
}
goTarIndexPage(index) {
if (!this.courses || index == this.courseIndex || index < 0 || index > this.courses.length - 1) {
return;
}
(<any>window).courseware.freeAllOcMethod();
this.courseIndex = index;
this.courseItem = this.courses[this.courseIndex];
this.loadPageBundle();
}
showTips(str) {
const tipsNode = new cc.Node();
tipsNode.parent = cc.find('Canvas');
tipsNode.zIndex = 100;
const bg = cc.instantiate(cc.find('middleLayer/bg'));
bg.parent = tipsNode;
bg.active = true;
bg.color = cc.color(100, 100, 100);
const labelNode = new cc.Node();
labelNode.parent = tipsNode;
const label = labelNode.addComponent(cc.Label);
label.string = str;
bg.width = 200;
bg.height = labelNode.height + 20;
cc.tween(tipsNode)
.set({ opacity: 255 })
.delay(1)
.to(1, { opacity: 0 })
.removeSelf()
.start();
}
log(str) {
cc.log(str);
}
}
function asyncDelay(arg0: number) {
throw new Error("Function not implemented.");
}
{
"ver": "1.0.8",
"uuid": "1b25c125-5f6c-4819-abcf-c852abb44e9e",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
......@@ -71,64 +71,64 @@ export function setSprNodeMaxLen(sprNode, maxW, maxH) {
}
export function localPosTolocalPos(baseNode, targetNode) {
const worldPos = targetNode.parent.convertToWorldSpaceAR(cc.v2(targetNode.x, targetNode.y));
const localPos = baseNode.parent.convertToNodeSpaceAR(cc.v2(worldPos.x, worldPos.y));
return localPos;
const worldPos = targetNode.parent.convertToWorldSpaceAR(cc.v2(targetNode.x, targetNode.y));
const localPos = baseNode.parent.convertToNodeSpaceAR(cc.v2(worldPos.x, worldPos.y));
return localPos;
}
export function worldPosToLocalPos(worldPos, baseNode) {
const localPos = baseNode.parent.convertToNodeSpaceAR(cc.v2(worldPos.x, worldPos.y));
return localPos;
const localPos = baseNode.parent.convertToNodeSpaceAR(cc.v2(worldPos.x, worldPos.y));
return localPos;
}
export function getScaleRateBy2Node(baseNode, targetNode, maxFlag = true) {
const worldRect1 = targetNode.getBoundingBoxToWorld();
const worldRect2 = baseNode.getBoundingBoxToWorld();
const sx = worldRect1.width / worldRect2.width;
const sy = worldRect1.height / worldRect2.height;
if (maxFlag) {
return Math.max(sx, sy);
} else {
return Math.min(sx, sy);
}
const worldRect1 = targetNode.getBoundingBoxToWorld();
const worldRect2 = baseNode.getBoundingBoxToWorld();
const sx = worldRect1.width / worldRect2.width;
const sy = worldRect1.height / worldRect2.height;
if (maxFlag) {
return Math.max(sx, sy);
} else {
return Math.min(sx, sy);
}
}
export function getDistance (start, end){
var pos = cc.v2(start.x - end.x, start.y - end.y);
var dis = Math.sqrt(pos.x*pos.x + pos.y*pos.y);
return dis;
export function getDistance(start, end) {
var pos = cc.v2(start.x - end.x, start.y - end.y);
var dis = Math.sqrt(pos.x * pos.x + pos.y * pos.y);
return dis;
}
export function playAudioByUrl(audio_url, cb=null) {
if (audio_url) {
cc.assetManager.loadRemote(audio_url, (err, audioClip) => {
export function 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();
});
}
});
}
});
}
}
export function btnClickAnima(btn, time=0.15, rate=1.05) {
export function btnClickAnima(btn, time = 0.15, rate = 1.05) {
btn.tmpScale = btn.scale;
btn.on(cc.Node.EventType.TOUCH_START, () => {
cc.tween(btn)
.to(time / 2, {scale: btn.scale * rate})
.to(time / 2, { scale: btn.scale * rate })
.start()
})
btn.on(cc.Node.EventType.TOUCH_CANCEL, () => {
cc.tween(btn)
.to(time / 2, {scale: btn.tmpScale})
.to(time / 2, { scale: btn.tmpScale })
.start()
})
btn.on(cc.Node.EventType.TOUCH_END, () => {
cc.tween(btn)
.to(time / 2, {scale: btn.tmpScale})
.to(time / 2, { scale: btn.tmpScale })
.start()
})
}
......@@ -165,7 +165,7 @@ export function getSprNodeByUrl(url, cb) {
export function playAudio(audioClip, cb = null) {
if (audioClip) {
const audioId = cc.audioEngine.playEffect(audioClip, false);
const audioId = cc.audioEngine.playEffect(audioClip, false, 0.8);
if (cb) {
cc.audioEngine.setFinishCallback(audioId, () => {
cb();
......@@ -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();
}, 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
......@@ -366,7 +296,7 @@ export async function asyncTweenTo(node, duration, obj, ease = undefined) {
cc.tween(node)
.to(duration, obj, ease)
.call(() => {
resolve(null);
resolve();
})
.start();
} catch (e) {
......@@ -381,7 +311,7 @@ export async function asyncTweenBy(node, duration, obj, ease = undefined) {
cc.tween(node)
.by(duration, obj, ease)
.call(() => {
resolve(null);
resolve();
})
.start();
} catch (e) {
......@@ -411,50 +341,19 @@ 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 = ()=>{}) {
export function onHomeworkFinish() {
const middleLayer = cc.find('middleLayer');
if (middleLayer) {
const middleLayerComponent = middleLayer.getComponent('middleLayer');
middleLayerComponent.onHomeworkFinish(callback, data);
if (middleLayerComponent.role == 'student') {
middleLayerComponent.onHomeworkFinish(() => { });
}
} else {
console.log('onHomeworkFinish', JSON.stringify(data));
console.log('onHomeworkFinish');
}
}
export function callMiddleLayerFunction(apiName: string, data: any, callback: Function) {
export function callMiddleLayerFunction(apiName, data, callback) {
const middleLayer = cc.find('middleLayer');
if (middleLayer) {
const middleLayerComponent = middleLayer.getComponent('middleLayer');
......@@ -464,3 +363,17 @@ export function callMiddleLayerFunction(apiName: string, data: any, callback: Fu
}
}
export function login() {
const middleLayer = cc.find('middleLayer');
if (middleLayer) {
const middleLayerComponent = middleLayer.getComponent('middleLayer');
middleLayerComponent.callMiddleLayerFunction('NS_login', {
userName: 'username123',
password: '1234567'
}, (result) => {
console.log(result);
});
} else {
console.log('NS_login');
}
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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