Commit fa703d42 authored by 范雪寒's avatar 范雪寒

feat: 格式化

parent 9cf134b4
...@@ -60,12 +60,12 @@ cc.Class({ ...@@ -60,12 +60,12 @@ cc.Class({
// 生命周期 start // 生命周期 start
start() { start() {
let getData = this.getData.bind(this); let getData = this.getData.bind(this);
if (window && window.courseware) { if (window && window.courseware) {
getData = window.courseware.getData; getData = window.courseware.getData;
} }
getData((data) => { getData((data) => {
console.log('data:', data); console.log('data:', data);
this.data = data || this.getDefaultData(); this.data = data || this.getDefaultData();
...@@ -84,7 +84,7 @@ cc.Class({ ...@@ -84,7 +84,7 @@ cc.Class({
const data = JSON.parse(dataJson); const data = JSON.parse(dataJson);
return data; return data;
}, },
preloadItem() { preloadItem() {
this.addPreloadImage(); this.addPreloadImage();
this.addPreloadAudio(); this.addPreloadAudio();
...@@ -95,13 +95,13 @@ cc.Class({ ...@@ -95,13 +95,13 @@ cc.Class({
addPreloadImage() { addPreloadImage() {
this._imageResList.push({url: this.data.pic_url}); this._imageResList.push({ url: this.data.pic_url });
this._imageResList.push({url: this.data.pic_url_2}); this._imageResList.push({ url: this.data.pic_url_2 });
}, },
addPreloadAudio() { addPreloadAudio() {
this._audioResList.push({url: this.data.audio_url}); this._audioResList.push({ url: this.data.audio_url });
}, },
addPreloadAnima() { addPreloadAnima() {
...@@ -117,7 +117,7 @@ cc.Class({ ...@@ -117,7 +117,7 @@ cc.Class({
if (window && window["air"]) { if (window && window["air"]) {
window["air"].hideAirClassLoading(); window["air"].hideAirClassLoading();
} }
cc.debug.setDisplayStats(false); cc.debug.setDisplayStats(false);
}); });
}, },
...@@ -135,7 +135,7 @@ cc.Class({ ...@@ -135,7 +135,7 @@ cc.Class({
// 所有全局变量 默认都是null // 所有全局变量 默认都是null
this._cantouch = true; this._cantouch = true;
}, },
audioBtn: null, audioBtn: null,
initAudio() { initAudio() {
const audioNode = cc.find('Canvas/res/audio'); const audioNode = cc.find('Canvas/res/audio');
...@@ -173,7 +173,7 @@ cc.Class({ ...@@ -173,7 +173,7 @@ cc.Class({
picNode1.scale = maxW / picNode1.width; picNode1.scale = maxW / picNode1.width;
picNode1.baseX = picNode1.x; picNode1.baseX = picNode1.x;
canvas.addChild(picNode1); canvas.addChild(picNode1);
this.pic1 = picNode1; this.pic1 = picNode1;
const labelNode = new cc.Node(); const labelNode = new cc.Node();
labelNode.color = cc.Color.YELLOW; labelNode.color = cc.Color.YELLOW;
...@@ -224,11 +224,11 @@ cc.Class({ ...@@ -224,11 +224,11 @@ cc.Class({
this.curPage = 0; this.curPage = 0;
const bottomPart = cc.find('Canvas/bottomPart'); const bottomPart = cc.find('Canvas/bottomPart');
bottomPart.zIndex = 5; // 提高层级 bottomPart.zIndex = 5; // 提高层级
bottomPart.x = bottomPart.parent.width / 2; bottomPart.x = bottomPart.parent.width / 2;
bottomPart.y = -bottomPart.parent.height / 2; bottomPart.y = -bottomPart.parent.height / 2;
const leftBtnNode = bottomPart.getChildByName('btn_left'); const leftBtnNode = bottomPart.getChildByName('btn_left');
//节点中添加了button组件 则可以添加click事件监听 //节点中添加了button组件 则可以添加click事件监听
leftBtnNode.on('click', () => { leftBtnNode.on('click', () => {
if (!this._cantouch) { if (!this._cantouch) {
...@@ -243,7 +243,7 @@ cc.Class({ ...@@ -243,7 +243,7 @@ cc.Class({
cc.audioEngine.play(this.audioBtn.clip, false, 0.8) cc.audioEngine.play(this.audioBtn.clip, false, 0.8)
}) })
const rightBtnNode = bottomPart.getChildByName('btn_right'); const rightBtnNode = bottomPart.getChildByName('btn_right');
//节点中添加了button组件 则可以添加click事件监听 //节点中添加了button组件 则可以添加click事件监听
rightBtnNode.on('click', () => { rightBtnNode.on('click', () => {
if (!this._cantouch) { if (!this._cantouch) {
...@@ -252,7 +252,7 @@ cc.Class({ ...@@ -252,7 +252,7 @@ cc.Class({
if (this.curPage == 1) { if (this.curPage == 1) {
return; return;
} }
this.curPage = 1 this.curPage = 1
this.rightMove(); this.rightMove();
...@@ -264,11 +264,11 @@ cc.Class({ ...@@ -264,11 +264,11 @@ cc.Class({
this._cantouch = false; this._cantouch = false;
const len = this.pic1.parent.width; const len = this.pic1.parent.width;
cc.tween(this.pic1) cc.tween(this.pic1)
.to(1, {x: this.pic1.baseX}, {easing: 'cubicInOut'}) .to(1, { x: this.pic1.baseX }, { easing: 'cubicInOut' })
.start(); .start();
cc.tween(this.pic2) cc.tween(this.pic2)
.to(1, {x: this.pic2.baseX}, {easing: 'cubicInOut'}) .to(1, { x: this.pic2.baseX }, { easing: 'cubicInOut' })
.call(() => { .call(() => {
this._cantouch = true; this._cantouch = true;
}) })
...@@ -279,18 +279,18 @@ cc.Class({ ...@@ -279,18 +279,18 @@ cc.Class({
this._cantouch = false; this._cantouch = false;
const len = this.pic1.parent.width; const len = this.pic1.parent.width;
cc.tween(this.pic1) cc.tween(this.pic1)
.to(1, {x: this.pic1.baseX - len}, {easing: 'cubicInOut'}) .to(1, { x: this.pic1.baseX - len }, { easing: 'cubicInOut' })
.start(); .start();
cc.tween(this.pic2) cc.tween(this.pic2)
.to(1, {x: this.pic2.baseX - len}, {easing: 'cubicInOut'}) .to(1, { x: this.pic2.baseX - len }, { easing: 'cubicInOut' })
.call(() => { .call(() => {
this._cantouch = true; this._cantouch = true;
}) })
.start(); .start();
}, },
// update (dt) {}, // update (dt) {},
...@@ -324,7 +324,7 @@ cc.Class({ ...@@ -324,7 +324,7 @@ cc.Class({
getSpriteFrimeByUrl(url, cb) { getSpriteFrimeByUrl(url, cb) {
cc.loader.load({url}, (err, img) => { cc.loader.load({ url }, (err, img) => {
const spriteFrame = new cc.SpriteFrame(img) const spriteFrame = new cc.SpriteFrame(img)
if (cb) { if (cb) {
cb(spriteFrame); cb(spriteFrame);
...@@ -343,7 +343,7 @@ cc.Class({ ...@@ -343,7 +343,7 @@ cc.Class({
}) })
}, },
playAudioByUrl(audio_url, cb=null) { playAudioByUrl(audio_url, cb = null) {
if (audio_url) { if (audio_url) {
cc.assetManager.loadRemote(audio_url, (err, audioClip) => { cc.assetManager.loadRemote(audio_url, (err, audioClip) => {
const audioId = cc.audioEngine.play(audioClip, false, 0.8); const audioId = cc.audioEngine.play(audioClip, false, 0.8);
......
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