Commit 9427ee84 authored by liujiangnan's avatar liujiangnan

feat: 主体功能

parent 73ff5aa0
{
"ver": "2.0.1",
"uuid": "d3f3a66c-51cd-4fcf-bc2b-8d424c4918d1",
"downloadMode": 0,
"duration": 2.319563,
"subMetas": {}
}
\ No newline at end of file
{ {
"ver": "2.0.1", "ver": "2.0.1",
"uuid": "4becf611-d0bc-4bd8-9bc9-b4d66646ada9", "uuid": "4641cae0-0d7a-4008-bc0e-ddf209310d28",
"downloadMode": 0, "downloadMode": 0,
"duration": 0.301724, "duration": 5.172245,
"subMetas": {} "subMetas": {}
} }
\ No newline at end of file
{ {
"ver": "2.0.1", "ver": "2.0.1",
"uuid": "4641cae0-0d7a-4008-bc0e-ddf209310d28", "uuid": "4becf611-d0bc-4bd8-9bc9-b4d66646ada9",
"downloadMode": 0, "downloadMode": 0,
"duration": 5.172245, "duration": 0.301724,
"subMetas": {} "subMetas": {}
} }
\ No newline at end of file
...@@ -96,19 +96,22 @@ ...@@ -96,19 +96,22 @@
"__id__": 120 "__id__": 120
}, },
{ {
"__id__": 124 "__id__": 122
},
{
"__id__": 134
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 136 "__id__": 140
}, },
{ {
"__id__": 137 "__id__": 141
}, },
{ {
"__id__": 138 "__id__": 142
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -4487,15 +4490,15 @@ ...@@ -4487,15 +4490,15 @@
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
"x": 0.5, "x": 1,
"y": 0.5 "y": 0.5
}, },
"_trs": { "_trs": {
"__type__": "TypedArray", "__type__": "TypedArray",
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
201, 704,
0, -252,
0, 0,
0, 0,
0, 0,
...@@ -5583,7 +5586,7 @@ ...@@ -5583,7 +5586,7 @@
"_target": null, "_target": null,
"_alignFlags": 32, "_alignFlags": 32,
"_left": 0, "_left": 0,
"_right": 515, "_right": 514,
"_top": 0, "_top": 0,
"_bottom": 0, "_bottom": 0,
"_verticalCenter": 0, "_verticalCenter": 0,
...@@ -5659,15 +5662,11 @@ ...@@ -5659,15 +5662,11 @@
"_parent": { "_parent": {
"__id__": 2 "__id__": 2
}, },
"_children": [ "_children": [],
{ "_active": true,
"__id__": 121
}
],
"_active": false,
"_components": [ "_components": [
{ {
"__id__": 123 "__id__": 121
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -5718,104 +5717,6 @@ ...@@ -5718,104 +5717,6 @@
"groupIndex": 0, "groupIndex": 0,
"_id": "a9KVtyd29NT4oPlOqOJ43+" "_id": "a9KVtyd29NT4oPlOqOJ43+"
}, },
{
"__type__": "cc.Node",
"_name": "ske",
"_objFlags": 0,
"_parent": {
"__id__": 120
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 122
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 460,
"height": 657
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
-45,
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": "3foWKNmFBE2bwtDbleufcI"
},
{
"__type__": "dragonBones.ArmatureDisplay",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 121
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_armatureName": "",
"_animationName": "",
"_preCacheMode": -1,
"_cacheMode": 0,
"playTimes": -1,
"premultipliedAlpha": false,
"_armatureKey": "",
"_accTime": 0,
"_playCount": 0,
"_frameCache": null,
"_curFrame": null,
"_playing": false,
"_armatureCache": null,
"_N$dragonAsset": null,
"_N$dragonAtlasAsset": null,
"_N$_defaultArmatureIndex": 0,
"_N$_animationIndex": 0,
"_N$_defaultCacheMode": 0,
"_N$timeScale": 1,
"_N$debugBones": false,
"_N$enableBatch": false,
"_id": "113vvkzfZN2a63NzB/bM+3"
},
{ {
"__type__": "cc.Button", "__type__": "cc.Button",
"_name": "", "_name": "",
...@@ -5893,16 +5794,16 @@ ...@@ -5893,16 +5794,16 @@
}, },
"_children": [ "_children": [
{ {
"__id__": 125 "__id__": 123
}, },
{ {
"__id__": 129 "__id__": 127
} }
], ],
"_active": false, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 135 "__id__": 133
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -5958,19 +5859,19 @@ ...@@ -5958,19 +5859,19 @@
"_name": "New Sprite(Splash)", "_name": "New Sprite(Splash)",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 124 "__id__": 122
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 126 "__id__": 124
}, },
{ {
"__id__": 127 "__id__": 125
}, },
{ {
"__id__": 128 "__id__": 126
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -6026,7 +5927,7 @@ ...@@ -6026,7 +5927,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 125 "__id__": 123
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -6058,7 +5959,7 @@ ...@@ -6058,7 +5959,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 125 "__id__": 123
}, },
"_enabled": true, "_enabled": true,
"alignMode": 1, "alignMode": 1,
...@@ -6085,7 +5986,7 @@ ...@@ -6085,7 +5986,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 125 "__id__": 123
}, },
"_enabled": true, "_enabled": true,
"_normalMaterial": null, "_normalMaterial": null,
...@@ -6153,20 +6054,20 @@ ...@@ -6153,20 +6054,20 @@
"_name": "f_group", "_name": "f_group",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 124 "__id__": 122
}, },
"_children": [ "_children": [
{ {
"__id__": 130 "__id__": 128
}, },
{ {
"__id__": 132 "__id__": 130
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 134 "__id__": 132
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -6222,13 +6123,13 @@ ...@@ -6222,13 +6123,13 @@
"_name": "final_title", "_name": "final_title",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 129 "__id__": 127
}, },
"_children": [], "_children": [],
"_active": false, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 131 "__id__": 129
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -6284,7 +6185,7 @@ ...@@ -6284,7 +6185,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 130 "__id__": 128
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -6316,13 +6217,13 @@ ...@@ -6316,13 +6217,13 @@
"_name": "desc", "_name": "desc",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 129 "__id__": 127
}, },
"_children": [], "_children": [],
"_active": false, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 133 "__id__": 131
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -6378,7 +6279,7 @@ ...@@ -6378,7 +6279,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 132 "__id__": 130
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -6413,7 +6314,7 @@ ...@@ -6413,7 +6314,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 129 "__id__": 127
}, },
"_enabled": true, "_enabled": true,
"alignMode": 1, "alignMode": 1,
...@@ -6440,7 +6341,7 @@ ...@@ -6440,7 +6341,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 124 "__id__": 122
}, },
"_enabled": true, "_enabled": true,
"alignMode": 1, "alignMode": 1,
...@@ -6462,6 +6363,295 @@ ...@@ -6462,6 +6363,295 @@
"_originalHeight": 1125, "_originalHeight": 1125,
"_id": "dee9bgrgVOBoUAmKCMwEMK" "_id": "dee9bgrgVOBoUAmKCMwEMK"
}, },
{
"__type__": "cc.Node",
"_name": "res",
"_objFlags": 0,
"_parent": {
"__id__": 2
},
"_children": [
{
"__id__": 135
}
],
"_active": false,
"_components": [],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_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": "403+XyrP9A343CTu57Qpqh"
},
{
"__type__": "cc.Node",
"_name": "audio",
"_objFlags": 0,
"_parent": {
"__id__": 134
},
"_children": [
{
"__id__": 136
},
{
"__id__": 138
}
],
"_active": true,
"_components": [],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_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": "0c1kPI/clJm7Y02oEAlGwd"
},
{
"__type__": "cc.Node",
"_name": "success",
"_objFlags": 0,
"_parent": {
"__id__": 135
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 137
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_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": "9ar9jnDwpOZ5e0v4HotZHK"
},
{
"__type__": "cc.AudioSource",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 136
},
"_enabled": true,
"_clip": {
"__uuid__": "4becf611-d0bc-4bd8-9bc9-b4d66646ada9"
},
"_volume": 1,
"_mute": false,
"_loop": false,
"_firstlyEnabled": true,
"playOnLoad": false,
"preload": false,
"_id": "b8qDw9BK9G/4r4TXhrpMmD"
},
{
"__type__": "cc.Node",
"_name": "upload",
"_objFlags": 0,
"_parent": {
"__id__": 135
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 139
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_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": "95lowPwttAJa1dV/qlta1m"
},
{
"__type__": "cc.AudioSource",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 138
},
"_enabled": true,
"_clip": {
"__uuid__": "4641cae0-0d7a-4008-bc0e-ddf209310d28"
},
"_volume": 1,
"_mute": false,
"_loop": false,
"_firstlyEnabled": true,
"playOnLoad": false,
"preload": false,
"_id": "e91Pc4tD9HqrIgKk2KzmE/"
},
{ {
"__type__": "cc.Canvas", "__type__": "cc.Canvas",
"_name": "", "_name": "",
...@@ -6514,6 +6704,21 @@ ...@@ -6514,6 +6704,21 @@
"__id__": 2 "__id__": 2
}, },
"_enabled": true, "_enabled": true,
"startNode": {
"__id__": 87
},
"page_view": {
"__id__": 100
},
"tip_label": {
"__id__": 98
},
"tip_left": {
"__id__": 108
},
"tip_right": {
"__id__": 112
},
"_id": "eaTVUpqahPfZeO9+sUI7RP" "_id": "eaTVUpqahPfZeO9+sUI7RP"
} }
] ]
\ No newline at end of file
import { buttonOnClick, buttonOnceClick, getSpriteFrimeByUrl, asyncLoadDragonBoneAnime, asyncDelay } from "../script/util"; import { buttonOnClick, buttonOnceClick, getSpriteFrimeByUrl,
asyncGetSpriteFrimeByUrl, playAudioByUrl, asyncLoadDragonBoneAnime,
asyncDelay, setNetImg } from "../script/util";
import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent"; import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent";
const { ccclass, property } = cc._decorator; const { ccclass, property } = cc._decorator;
...@@ -7,6 +9,21 @@ const { ccclass, property } = cc._decorator; ...@@ -7,6 +9,21 @@ const { ccclass, property } = cc._decorator;
export default class SceneComponent extends MyCocosSceneComponent { export default class SceneComponent extends MyCocosSceneComponent {
@property(cc.Node)
startNode: cc.Node = null;
@property(cc.Node)
page_view: cc.Node = null;
@property(cc.Node)
tip_label: cc.Node = null;
@property(cc.Node)
tip_left: cc.Node = null;
@property(cc.Node)
tip_right: cc.Node = null;
addPreloadImage() { addPreloadImage() {
// TODO 根据自己的配置预加载图片资源 // TODO 根据自己的配置预加载图片资源
} }
...@@ -56,7 +73,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -56,7 +73,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
async onLoadEnd() { async onLoadEnd() {
// TODO 加载完成后的逻辑写在这里, 下面的代码仅供参考 // TODO 加载完成后的逻辑写在这里, 下面的代码仅供参考
this.initData(); this.initData();
this.initView(); await this.initView();
await this.asyncDrawAnswer(); await this.asyncDrawAnswer();
this.initListener(); this.initListener();
} }
...@@ -68,8 +85,9 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -68,8 +85,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
} }
picture_url = null; picture_url = null;
initView() { async initView() {
this.initBg(); this.initBg();
await this.initTips();
window["cameraHandler"].takePictureCallback = (err, url) => { window["cameraHandler"].takePictureCallback = (err, url) => {
if (err) { if (err) {
console.log(err); console.log(err);
...@@ -84,6 +102,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -84,6 +102,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
getSpriteFrimeByUrl(url, (frame) => { getSpriteFrimeByUrl(url, (frame) => {
pic.getComponent(cc.Sprite).spriteFrame = frame; pic.getComponent(cc.Sprite).spriteFrame = frame;
pic.active = true; pic.active = true;
this.playLocalAudio("picload");
this.hideLoading(); this.hideLoading();
}); });
} }
...@@ -95,9 +114,56 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -95,9 +114,56 @@ export default class SceneComponent extends MyCocosSceneComponent {
bgNode.scale = this._mapScaleMax; bgNode.scale = this._mapScaleMax;
} }
async initTips() {
if (this.data.tipSwitch == 0) {
cc.find("btn_start", this.node).active = false;
return;
}
this.startNode.active = true;
const data: any = await setNetImg(cc.find("s_group/startbg", this.startNode), this.data.tipBg, { w: 0, h: 0 }, false);
this.page_view.width = data.w - 240;
this.page_view.height = data.h - 200;
this.page_view.x = -(data.w / 2);
this.data.tipPage.forEach((dt, idx) => {
let desc = cc.instantiate(this.tip_label);
desc.getComponent(cc.Label).string = dt.title;
desc.width = this.page_view.width;
desc.height = this.page_view.height - 40;
this.page_view.getComponent(cc.PageView).addPage(desc);
desc.active = true;
desc["data"] = dt;
})
this.updataTipArrow();
const btnStart = cc.find("btn_start", this.node);
await asyncLoadDragonBoneAnime(btnStart, {
skeJsonData: this.data.imgAni.ske,
texJsonData: this.data.imgAni.tex,
texPngData: this.data.imgAni.png
});
const animaNode = btnStart['animaNode'];
const db = animaNode.getComponent(dragonBones.ArmatureDisplay);
let anis = db.getAnimationNames("armatureName");
db.playAnimation(anis[0], 0);
}
updataTipArrow() {
let index = this.page_view.getComponent(cc.PageView).getCurrentPageIndex();
let pages = this.page_view.getComponent(cc.PageView).getPages();
this.tip_left.active = pages.length > 0 && index > 0;
this.tip_right.active = pages.length > 0 && index < pages.length - 1;
let page = pages[index];
if (page)
playAudioByUrl(page["data"].audio);
}
initListener() { initListener() {
const btn = cc.find(`Canvas/border/upload`); const btn = cc.find(`Canvas/border/upload`);
buttonOnClick(btn, () => { buttonOnClick(btn, () => {
this.playLocalAudio("upload");
this.showLoading(); this.showLoading();
window["cameraHandler"].openCamera(); window["cameraHandler"].openCamera();
}); });
...@@ -119,6 +185,31 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -119,6 +185,31 @@ export default class SceneComponent extends MyCocosSceneComponent {
console.log("==切换下一页=="); console.log("==切换下一页==");
} }
}); });
const btnStart = cc.find("btn_start", this.node);
btnStart.on('click', () => {
if (btnStart['cantClick']) {
return;
}
btnStart['cantClick'] = true;
this.startNode.active = true;
let start_ske = btnStart['animaNode'];
cc.tween(start_ske).to(0.2, { scale: 1 }).start();
this.updataTipArrow();
});
buttonOnClick(cc.find("s_group/startbg/btn_close", this.startNode), () => {
cc.audioEngine.stopAll();
const btnStart = cc.find("btn_start", this.node);
let start_ske = btnStart['animaNode'];
cc.tween(start_ske).to(0.2, { scale: 0.3 }).call(() => {
cc.find("btn_start", this.node)['cantClick'] = false;
}).start();
this.page_view.getComponent(cc.PageView).setCurrentPageIndex(0);
this.startNode.active = false;
});
} }
async showFinal() { async showFinal() {
...@@ -133,12 +224,13 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -133,12 +224,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
texJsonData: this.data.endImgAni.tex, texJsonData: this.data.endImgAni.tex,
texPngData: this.data.endImgAni.png texPngData: this.data.endImgAni.png
}); });
const animaNode = f_group['animaNode']; const animaNode = f_group['animaNode'];
const db = animaNode.getComponent(dragonBones.ArmatureDisplay); const db = animaNode.getComponent(dragonBones.ArmatureDisplay);
let anis = db.getAnimationNames("armatureName"); let anis = db.getAnimationNames("armatureName");
db.playAnimation(anis[0], 0); db.playAnimation(anis[0], 0);
this.playLocalAudio("success");
final.active = true; final.active = true;
let desc = cc.find("desc", f_group); let desc = cc.find("desc", f_group);
let final_title = cc.find("final_title", f_group); let final_title = cc.find("final_title", f_group);
...@@ -161,13 +253,9 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -161,13 +253,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
} }
playLocalAudio(audioName) { playLocalAudio(audioName) {
cc.audioEngine.stopAll();
const audio = cc.find(`Canvas/res/audio/${audioName}`).getComponent(cc.AudioSource); const audio = cc.find(`Canvas/res/audio/${audioName}`).getComponent(cc.AudioSource);
return new Promise((resolve, reject) => { cc.audioEngine.playEffect(audio.clip, false);
const id = cc.audioEngine.playEffect(audio.clip, false);
cc.audioEngine.setFinishCallback(id, () => {
resolve(id);
});
})
} }
onLeave(cb) { onLeave(cb) {
......
...@@ -19,7 +19,7 @@ export const defaultData = { ...@@ -19,7 +19,7 @@ export const defaultData = {
"tipPage": [ "tipPage": [
{ {
"title": "这么小的院子里,居然同时有一间书房和一间书院,这家人可真喜欢读书啊。", "title": "这么小的院子里,居然同时有一间书房和一间书院,这家人可真喜欢读书啊。",
"audio": "" "audio": "https://staging-teach.cdn.ireadabc.com/c03129693e6cabf061661fba349fa031.mp3"
} }
], ],
"title": "", "title": "",
......
...@@ -143,6 +143,54 @@ export function getSpriteFrimeByUrl(url, cb) { ...@@ -143,6 +143,54 @@ export function getSpriteFrimeByUrl(url, cb) {
}) })
} }
export function asyncGetSpriteFrimeByUrl(url) {
return new Promise((resolve, reject) => {
cc.loader.load({ url }, (err, img) => {
if (err) {
reject(err);
return;
}
const spriteFrame = new cc.SpriteFrame(img)
resolve(spriteFrame);
})
});
}
export function setNetImg(item, res, { w, h }, custom = true) {
return new Promise((resolve, reject) => {
if (!item) return console.warn("图片更换失败,传入了错误的item");
let node = item.node ? item.node : item;
if (!res) {
if (node) node.active = false;
return console.warn("图片更换失败,传入了错误的res");
}
if (!node) return console.warn("图片更换失败,传入了错误的item");
if (node.net_url == res) return;
node.active = false;//
cc.loader.load({ url: res }, (err, texture) => {
if (err && !texture) return resolve(console.warn('loading loadRes warn-> ' + texture));
if (!cc.isValid(node)) return console.info("节点已销毁");
let nw = node.width = texture.width;
let nh = node.height = texture.height;
let component = node.getComponent(cc.Sprite);
let spriteFrame = new cc.SpriteFrame(texture);
component.spriteFrame = spriteFrame;
node.net_url = res;
if (!cc.isValid(node)) return console.info("节点已销毁");
if (!node) return console.warn("节点已销毁");
if (w && h && custom) {
let scaleX = w / nw;
let scaleY = h / nh;
let scale = scaleX <= scaleY ? scaleX : scaleY;
node.width = nw * scale;
node.height = nh * scale;
}
node.active = true;
resolve({ w: nw, h: nh });
});
})
}
export function getSprNode(resName) { export function getSprNode(resName) {
const sf = cc.find('Canvas/res/img/' + resName).getComponent(cc.Sprite).spriteFrame; const sf = cc.find('Canvas/res/img/' + resName).getComponent(cc.Sprite).spriteFrame;
const node = new cc.Node(); const node = new cc.Node();
......
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