Commit 2ad39261 authored by limingzhe's avatar limingzhe

feat: ui调整

parent b8e0d5cf
No preview for this file type
{
"ver": "2.0.1",
"uuid": "ad3f8d69-10b9-47f2-8168-6afd2a6247cf",
"downloadMode": 0,
"duration": 1.776327,
"subMetas": {}
}
\ No newline at end of file
import { initAir } from './air';
import { playAudio, showBigStar } from './util';
cc.Class({
extends: cc.Component,
properties: {
......@@ -77,6 +78,7 @@ cc.Class({
this.preloadCount = 0;
this.loadedCount = 0;
initAir(this);
this.initAudio();
},
start() {
......@@ -93,6 +95,10 @@ cc.Class({
});
},
initAudio() {
this.bigStarClip = cc.find('middleLayer/res/audio/big_star').getComponent(cc.AudioSource).clip;
},
initTerminalInfo(callback) {
window.courseware.getEngineInfo(res => {
const { isDev, uuid } = JSON.parse(res);
......@@ -143,14 +149,16 @@ cc.Class({
user_code: this.userCode,
}, res => {
if (res.code === 200) {
const starLabel = cc.find('middleLayer/star_count_label').getComponent(cc.Label);
starLabel.string = res.data;
// const starLabel = cc.find('middleLayer/star_count_label').getComponent(cc.Label);
const starLabel = cc.find('middleLayer/star_node/star_count_label').getComponent(cc.RichText);
starLabel.string = `<outline color=black width=2><b>${res.data} </b></outline>` ;
}else{
console.log("-----error------");
console.log(res.msg);
// TODO 提示错误和上报错误
}
});
},
initPageInfo() {
......@@ -194,6 +202,24 @@ cc.Class({
if(animationFlag){
// TODO 添加星星的动画
for (let i=0; i<count; i++) {
setTimeout(() => {
let star = cc.find('middleLayer/star_node/icon_star');
const resItem = cc.find('middleLayer/res/icon_bigstar');
const starBig = cc.instantiate(resItem);
starBig.parent = star.parent;
showBigStar(starBig, star);
}, i * 500);
}
playAudio(this.bigStarClip);
}
this.callNetworkApiPost(this.baseApiUrl, `v1/terminal/star/save`, {
......@@ -204,6 +230,8 @@ cc.Class({
stars: count,
})
},
preloadAll() {
if (window.preloadBundleAndSourcesFlag) {
......@@ -489,7 +517,7 @@ cc.Class({
if (this.courseIndex == this.courses.length - 1) {
cc.find('middleLayer/BtnRight').active = false;
} else {
cc.find('middleLayer/BtnRight').active = true;
// cc.find('middleLayer/BtnRight').active = true;
}
this.loadPageBundle();
},
......@@ -542,7 +570,7 @@ cc.Class({
this.courseItem = data.rows[this.courseIndex];
}
if (this.courses && this.courses.length > 1 && this.courseIndex <= this.courses.length - 1) {
cc.find('middleLayer/BtnRight').active = true;
// cc.find('middleLayer/BtnRight').active = true;
}
if (this.courseIndex > 0) {
cc.find('middleLayer/BtnLeft').active = false;
......
......@@ -168,7 +168,7 @@ export function playAudio(audioClip, cb = null) {
const audioId = cc.audioEngine.playEffect(audioClip, false, 0.8);
if (cb) {
cc.audioEngine.setFinishCallback(audioId, () => {
cb();
cb && cb();
});
}
}
......@@ -305,6 +305,62 @@ export async function asyncTweenTo(node, duration, obj, ease = undefined) {
});
}
export function showBigStar(starJump, starBase, cb=null) {
const bigStarBg = cc.instantiate(starJump);
bigStarBg.scale = starJump.width / starBase.width / 1.2;
starBase.scale = 1;
// const star = bigStarBg.star;
starJump.active = true;
starJump.scaleX = 0.7 / bigStarBg.scale;
starJump.scaleY = 1 / bigStarBg.scale;
// starJump.angle = 90;
const canvas = cc.find('Canvas');
const startPos = exchangeNodePos(starJump.parent, canvas, cc.v2(0, -canvas.height / 2));
const middlePos = exchangeNodePos(starJump.parent, canvas, cc.v2(0, -canvas.height / 4));
starJump.x = startPos.x + Math.random() * 100 - 50;
starJump.y = startPos.y - starBase.height;
console.log('middlePos = ' + JSON.stringify(middlePos));
const time = 1;
cc.tween(starJump)
.to(0.3, { y: middlePos.y + 60 }, { easing: 'quadOut' })
.to(0.1, { y: middlePos.y + 30, scaleX: 1.2 / bigStarBg.scale, scaleY: 0.8 / bigStarBg.scale }, { easing: 'quadOut' })
.to(0.1, { y: middlePos.y, scaleX: 1 / bigStarBg.scale, scaleY: 1 / bigStarBg.scale }, { easing: 'quadOut' })
.delay(0.1)
.to(0.8, { angle: -720, scale: 1 })
.start();
cc.tween(starJump)
.delay(0.6)
.to(0.8, { x: starBase.x }, { easing: 'sineOut' })
.start();
cc.tween(starJump)
.delay(0.6)
.to(0.8, { y: starBase.y }, { easing: 'backIn' })
.start();
cc.tween(starJump)
.delay(0.6)
.to(0.8, { scale: starBase.width/starJump.width * 0.5 }, { easing: 'quadOut' })
.call(() => {
starJump.removeFromParent();
cb && cb()
})
.start();
cc.tween(starBase)
.delay(1.4)
.to(0.1, { scale: 1.2 }, { easing: 'sineInOut' })
.to(1.1, { scale: 1 }, { easing: 'elasticOut' })
.start();
}
export async function asyncTweenBy(node, duration, obj, ease = undefined) {
return new Promise((resolve, reject) => {
try {
......
{
"ver": "1.1.0",
"uuid": "b019349c-fa93-4ed9-81a3-2636d3b165aa",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "8ebdae24-6add-45f8-8735-310821c49bd7",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 171,
"height": 146,
"platformSettings": {},
"subMetas": {
"btn_coode": {
"ver": "1.0.4",
"uuid": "f89b7f7d-86c6-40be-8cc9-f4440dd10140",
"rawTextureUuid": "8ebdae24-6add-45f8-8735-310821c49bd7",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 171,
"height": 146,
"rawWidth": 171,
"rawHeight": 146,
"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