Commit 47c38f7f authored by liujiangnan's avatar liujiangnan

feat

parent 8061dd77
{
"ver": "1.1.0",
"uuid": "3741626d-31d9-4420-9d18-0f74cb48c733",
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
import { buttonOnClick, onHomeworkFinish, getSpriteFrimeByUrl } from "../script/util"; import { buttonOnClick, buttonOnceClick, getSpriteFrimeByUrl } from "../script/util";
import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent"; import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent";
const { ccclass, property } = cc._decorator; const { ccclass, property } = cc._decorator;
...@@ -26,10 +26,34 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -26,10 +26,34 @@ export default class SceneComponent extends MyCocosSceneComponent {
cc.find(`Canvas/loading`).active = false; cc.find(`Canvas/loading`).active = false;
} }
onLoadEnd() { isOver = false;
asyncDrawAnswer() {
return new Promise((resolve, reject) => {
if (window && window["courseware"]) {
window["courseware"].getAnswer(null, ans => {
if (ans) {
this.isOver = JSON.parse(ans).isOver;
const pic = cc.find(`Canvas/border/pic_bg/picture`);
getSpriteFrimeByUrl(JSON.parse(ans).pic_url, (frame) => {
pic.getComponent(cc.Sprite).spriteFrame = frame;
pic.active = true;
resolve();
});
} else {
resolve();
}
});
} else {
resolve();
}
});
}
async onLoadEnd() {
// TODO 加载完成后的逻辑写在这里, 下面的代码仅供参考 // TODO 加载完成后的逻辑写在这里, 下面的代码仅供参考
this.initData(); this.initData();
this.initView(); this.initView();
await this.asyncDrawAnswer();
this.initListener(); this.initListener();
} }
...@@ -42,12 +66,18 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -42,12 +66,18 @@ export default class SceneComponent extends MyCocosSceneComponent {
initView() { initView() {
this.initBg(); this.initBg();
window["cameraHandler"].takePictureCallback = (err, url) => { window["cameraHandler"].takePictureCallback = (err, url) => {
if (err) { if (err) {
console.log(err); console.log(err);
this.hideLoading(); this.hideLoading();
return; return;
} }
// 上报答题结果
if (window && window["courseware"]) {
window["courseware"].sendAnswer({isOver: true, pic_url: url});
}
const pic = cc.find(`Canvas/border/pic_bg/picture`); const pic = cc.find(`Canvas/border/pic_bg/picture`);
getSpriteFrimeByUrl(url, (frame) => { getSpriteFrimeByUrl(url, (frame) => {
pic.getComponent(cc.Sprite).spriteFrame = frame; pic.getComponent(cc.Sprite).spriteFrame = frame;
...@@ -80,4 +110,86 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -80,4 +110,86 @@ export default class SceneComponent extends MyCocosSceneComponent {
}) })
} }
onLeave(cb) {
if (!this.isOver) {
const tips = cc.find("tips", this.node);
cc.find(`continue`, tips).active = true;
cc.find(`leave`, tips).active = true;
cc.find(`btn_bl`, tips).active = false;
cc.find(`btn_zcdt`, tips).active = false;
tips.active = true;
cc.find(`desc`, tips).getComponent(cc.Label).string = "确定放弃本次答题么?";
buttonOnceClick(cc.find(`continue`, tips), () => {
tips.active = false;
});
buttonOnceClick(cc.find(`leave`, tips), () => {
tips.active = false;
cb();
});
} else {
cb();
}
}
goBack() {
this.onLeave(() => {
const middleLayer = cc.find('middleLayer');
if (middleLayer) {
const mc = middleLayer.getComponent('middleLayer');
// 切换上一页
mc.goPrePage();
} else {
console.log("==切换上一页==");
}
});
}
goNext() {
this.onLeave(() => {
const middleLayer = cc.find('middleLayer');
if (middleLayer) {
const mc = middleLayer.getComponent('middleLayer');
// // 切换下一页
mc.goNextPage();
} else {
console.log("==切换下一页==");
}
});
}
goHome() {
this.onLeave(() => {
const middleLayer = cc.find('middleLayer');
if (middleLayer) {
const mc = middleLayer.getComponent('middleLayer');
// 回首页
mc.goTarIndexPage(0);
} else {
console.log("==回首页==");
}
});
}
goRestart() {
const tips = cc.find("tips", this.node);
cc.find(`continue`, tips).active = false;
cc.find(`leave`, tips).active = false;
cc.find(`btn_bl`, tips).active = true;
cc.find(`btn_zcdt`, tips).active = true;
tips.active = true;
cc.find(`desc`, tips).getComponent(cc.Label).string = "确定重新开始么?";
buttonOnceClick(cc.find(`btn_bl`, tips), () => {
tips.active = false;
});
buttonOnceClick(cc.find(`btn_zcdt`, tips), () => {
tips.active = false;
const pic = cc.find(`Canvas/border/pic_bg/picture`);
pic.getComponent(cc.Sprite).spriteFrame = null;
pic.active = false;
});
}
} }
...@@ -87,7 +87,7 @@ export class MyCocosSceneComponent extends cc.Component { ...@@ -87,7 +87,7 @@ export class MyCocosSceneComponent extends cc.Component {
preload() { preload() {
const preloadArr = this._imageResList.concat(this._audioResList).concat(this._animaResList); const preloadArr = this._imageResList.concat(this._audioResList).concat(this._animaResList);
cc.assetManager.loadAny(preloadArr, null, null, (err, data) => { cc.assetManager.loadAny(preloadArr, null, null, async (err, data) => {
if (window && window["air"]) { if (window && window["air"]) {
// window["air"].onCourseInScreen = (next) => { // window["air"].onCourseInScreen = (next) => {
...@@ -95,7 +95,7 @@ export class MyCocosSceneComponent extends cc.Component { ...@@ -95,7 +95,7 @@ export class MyCocosSceneComponent extends cc.Component {
// this.onLoadEnd(); // this.onLoadEnd();
// next(); // next();
// }; // };
this.onLoadEnd(); await this.onLoadEnd();
window["air"].hideAirClassLoading(); window["air"].hideAirClassLoading();
} else { } else {
this.onLoadEnd(); this.onLoadEnd();
......
...@@ -464,6 +464,26 @@ export function callMiddleLayerFunction(apiName: string, data: any, callback: Fu ...@@ -464,6 +464,26 @@ export function callMiddleLayerFunction(apiName: string, data: any, callback: Fu
} }
} }
export function buttonOnceClick(button, callback, scale = 1.0) {
button.addComponent(cc.Button);
const func = () => {
if (button['cantClick']) {
return;
}
button['cantClick'] = true;
cc.tween(button)
.to(0.1, { scale: scale * 1.1 })
.to(0.1, { scale: scale })
.call(() => {
button['cantClick'] = false;
callback && callback();
})
.start();
}
button.off('click');
button.once('click', func);
}
export function buttonOnClick(button, callback, scale = 1.0) { export function buttonOnClick(button, callback, scale = 1.0) {
button.on('click', () => { button.on('click', () => {
if (button['cantClick']) { if (button['cantClick']) {
......
{
"ver": "2.3.5",
"uuid": "5a81e0e0-0253-489c-ace3-30f005656a02",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 59,
"height": 60,
"platformSettings": {},
"subMetas": {
"again0": {
"ver": "1.0.4",
"uuid": "745d21b5-2a0f-4a0e-ba58-d235bb05c3c8",
"rawTextureUuid": "5a81e0e0-0253-489c-ace3-30f005656a02",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 59,
"height": 60,
"rawWidth": 59,
"rawHeight": 60,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "af596d4c-9cb5-4bf5-a233-86b013b1fffd",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 71,
"height": 72,
"platformSettings": {},
"subMetas": {
"again1": {
"ver": "1.0.4",
"uuid": "7af8962a-9d6a-4f53-a219-a7bbd54e8630",
"rawTextureUuid": "af596d4c-9cb5-4bf5-a233-86b013b1fffd",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 71,
"height": 72,
"rawWidth": 71,
"rawHeight": 72,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "36a0a4cc-a278-468c-9997-4a211ac504b7",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 52,
"height": 51,
"platformSettings": {},
"subMetas": {
"back0": {
"ver": "1.0.4",
"uuid": "c9e84ee0-c302-41f5-b386-bbe4862b2a90",
"rawTextureUuid": "36a0a4cc-a278-468c-9997-4a211ac504b7",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 52,
"height": 51,
"rawWidth": 52,
"rawHeight": 51,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "2e3a6741-4307-4637-8a87-629dbd40065c",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 64,
"height": 63,
"platformSettings": {},
"subMetas": {
"back1": {
"ver": "1.0.4",
"uuid": "3b74183b-a8ed-4489-ab3e-45ee747ab1e7",
"rawTextureUuid": "2e3a6741-4307-4637-8a87-629dbd40065c",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 64,
"height": 63,
"rawWidth": 64,
"rawHeight": 63,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "2.3.5",
"uuid": "6ca5831b-362f-4c87-b80f-0fe590d65cde",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 2436,
"height": 959,
"platformSettings": {},
"subMetas": {
"bg1": {
"ver": "1.0.4",
"uuid": "8644ceb5-9e36-42b6-bae6-841fdcf0f547",
"rawTextureUuid": "6ca5831b-362f-4c87-b80f-0fe590d65cde",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 2436,
"height": 959,
"rawWidth": 2436,
"rawHeight": 959,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "63f9c8b7-f87f-4c86-926a-c99f2eb81c65",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 167,
"height": 117,
"platformSettings": {},
"subMetas": {
"btn_bl": {
"ver": "1.0.4",
"uuid": "b499a561-374b-4543-a7b6-125a6bb66aaf",
"rawTextureUuid": "63f9c8b7-f87f-4c86-926a-c99f2eb81c65",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 167,
"height": 117,
"rawWidth": 167,
"rawHeight": 117,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "311a2474-cb87-47fb-a6cf-6d73e912de4e",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 241,
"height": 117,
"platformSettings": {},
"subMetas": {
"btn_zcdt": {
"ver": "1.0.4",
"uuid": "c3a20438-5f43-4c89-8805-9a094b77eb81",
"rawTextureUuid": "311a2474-cb87-47fb-a6cf-6d73e912de4e",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 241,
"height": 117,
"rawWidth": 241,
"rawHeight": 117,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "c1f8b255-ed37-42d8-ac52-3b52728b2813",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 715,
"height": 147,
"platformSettings": {},
"subMetas": {
"btnbg": {
"ver": "1.0.4",
"uuid": "f673eff1-a306-4ae1-9d2f-ca45b98211fb",
"rawTextureUuid": "c1f8b255-ed37-42d8-ac52-3b52728b2813",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 715,
"height": 147,
"rawWidth": 715,
"rawHeight": 147,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "5babffdf-2e98-4609-a08b-ff50f57818c0",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 241,
"height": 117,
"platformSettings": {},
"subMetas": {
"continue": {
"ver": "1.0.4",
"uuid": "4979f982-e603-4e17-b723-3b77b4363949",
"rawTextureUuid": "5babffdf-2e98-4609-a08b-ff50f57818c0",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 241,
"height": 117,
"rawWidth": 241,
"rawHeight": 117,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "866a732d-8e2a-406e-9a44-05a81ecd5611",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 138,
"height": 140,
"platformSettings": {},
"subMetas": {
"iconbg": {
"ver": "1.0.4",
"uuid": "00722fe4-fbc2-4ca8-a3a0-977425c5c864",
"rawTextureUuid": "866a732d-8e2a-406e-9a44-05a81ecd5611",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 138,
"height": 140,
"rawWidth": 138,
"rawHeight": 140,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "bceb47f1-f187-4de5-8a39-49424df5ab25",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 167,
"height": 117,
"platformSettings": {},
"subMetas": {
"leave": {
"ver": "1.0.4",
"uuid": "394662db-5bf7-4385-a1d3-ef3c8b39b583",
"rawTextureUuid": "bceb47f1-f187-4de5-8a39-49424df5ab25",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 167,
"height": 117,
"rawWidth": 167,
"rawHeight": 117,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "c868c2b7-c62c-4728-9dd2-41b47c4711ca",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 52,
"height": 51,
"platformSettings": {},
"subMetas": {
"next0": {
"ver": "1.0.4",
"uuid": "24acab40-70cb-4db8-8ad6-2b574d0bc696",
"rawTextureUuid": "c868c2b7-c62c-4728-9dd2-41b47c4711ca",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 52,
"height": 51,
"rawWidth": 52,
"rawHeight": 51,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "436c155d-7009-4d90-9c71-555a279d21e6",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 64,
"height": 63,
"platformSettings": {},
"subMetas": {
"next1": {
"ver": "1.0.4",
"uuid": "e25db3f5-44af-41b6-85c5-6f61494a37b4",
"rawTextureUuid": "436c155d-7009-4d90-9c71-555a279d21e6",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 64,
"height": 63,
"rawWidth": 64,
"rawHeight": 63,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "a0b33a01-e236-4712-b2f3-7c0966576738",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 63,
"height": 48,
"platformSettings": {},
"subMetas": {
"revoke0": {
"ver": "1.0.4",
"uuid": "bfe36ec5-3a9d-4b58-9345-867c13fc3fd6",
"rawTextureUuid": "a0b33a01-e236-4712-b2f3-7c0966576738",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 63,
"height": 48,
"rawWidth": 63,
"rawHeight": 48,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "5727eb0e-5a83-45be-83c3-ee8f18380f77",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 75,
"height": 60,
"platformSettings": {},
"subMetas": {
"revoke1": {
"ver": "1.0.4",
"uuid": "31810283-c5ed-4859-a3ef-e11d9a182c74",
"rawTextureUuid": "5727eb0e-5a83-45be-83c3-ee8f18380f77",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 75,
"height": 60,
"rawWidth": 75,
"rawHeight": 60,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "bceb0941-6524-43ef-b1d8-e401ac7d878c",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 896,
"height": 353,
"platformSettings": {},
"subMetas": {
"tipbg": {
"ver": "1.0.4",
"uuid": "06f9e5fc-bf0c-4dfc-b3ee-18c76e3fe9f0",
"rawTextureUuid": "bceb0941-6524-43ef-b1d8-e401ac7d878c",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 896,
"height": 353,
"rawWidth": 896,
"rawHeight": 353,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
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