Commit 1ef63a75 authored by 范雪寒's avatar 范雪寒

style: format

parent 2a872c7e
...@@ -38,7 +38,7 @@ cc.Class({ ...@@ -38,7 +38,7 @@ cc.Class({
// }, // },
}, },
setCurrentMode(val) { setCurrentMode(val) {
if(this.__currentMode__ === val) { if (this.__currentMode__ === val) {
return; return;
} }
...@@ -56,10 +56,10 @@ cc.Class({ ...@@ -56,10 +56,10 @@ cc.Class({
}, },
convertBoundingCoordinate(node, targetRect, resize) { convertBoundingCoordinate(node, targetRect, resize) {
const baseOn = node.parent; // targetRect.parent ? targetRect.parent : this.node;//cc.find('Canvas');//targetRect.parent;// cc.find('Canvas'); const baseOn = node.parent; // targetRect.parent ? targetRect.parent : this.node;//cc.find('Canvas');//targetRect.parent;// cc.find('Canvas');
const worldPos = baseOn.convertToWorldSpaceAR(cc.v2(targetRect.x , targetRect.y)); const worldPos = baseOn.convertToWorldSpaceAR(cc.v2(targetRect.x, targetRect.y));
const localPos = node._parent.convertToNodeSpaceAR(cc.v2(worldPos.x, worldPos.y)); const localPos = node._parent.convertToNodeSpaceAR(cc.v2(worldPos.x, worldPos.y));
const worldPos2 = baseOn.convertToWorldSpaceAR(cc.v2(targetRect.x + targetRect.width , targetRect.y + targetRect.height)); const worldPos2 = baseOn.convertToWorldSpaceAR(cc.v2(targetRect.x + targetRect.width, targetRect.y + targetRect.height));
const localPos2 = node._parent.convertToNodeSpaceAR(cc.v2(worldPos2.x, worldPos2.y)); const localPos2 = node._parent.convertToNodeSpaceAR(cc.v2(worldPos2.x, worldPos2.y));
// this.actionButton.node.x = localPos.x; // this.actionButton.node.x = localPos.x;
...@@ -78,12 +78,12 @@ cc.Class({ ...@@ -78,12 +78,12 @@ cc.Class({
node.y = (localPos2.y + localPos.y) / 2; node.y = (localPos2.y + localPos.y) / 2;
node.x = (localPos2.x + localPos.x) / 2; node.x = (localPos2.x + localPos.x) / 2;
const {x, y, width, height} = node; const { x, y, width, height } = node;
console.log(2, {x, y, width, height} ) console.log(2, { x, y, width, height })
}, },
setNodeScale() { setNodeScale() {
const {width: dw, height: dh} = cc.view.getDesignResolutionSize(); const { width: dw, height: dh } = cc.view.getDesignResolutionSize();
const {width: fw, height: fh} = cc.view.getFrameSize(); const { width: fw, height: fh } = cc.view.getFrameSize();
const gameScale = Math.min(dw / fw, dh / fh); const gameScale = Math.min(dw / fw, dh / fh);
let sx = fw / dw; let sx = fw / dw;
...@@ -96,12 +96,12 @@ cc.Class({ ...@@ -96,12 +96,12 @@ cc.Class({
this.node.scale = Math.min(sx, sy) this.node.scale = Math.min(sx, sy)
}, },
getOffsetY() { getOffsetY() {
const {width: dw, height: dh} = cc.view.getDesignResolutionSize(); const { width: dw, height: dh } = cc.view.getDesignResolutionSize();
const {width: fw, height: fh} = cc.view.getFrameSize(); const { width: fw, height: fh } = cc.view.getFrameSize();
const gameScale = Math.min(dw / fw, dh / fh); const gameScale = Math.min(dw / fw, dh / fh);
const cw = this.node.width; const cw = this.node.width;
const ch = this.node.height; const ch = this.node.height;
return fh / 2 * gameScale - ch / 2 * this.node.scaleY ; return fh / 2 * gameScale - ch / 2 * this.node.scaleY;
}, },
setToRectArea(node, conf, resize) { setToRectArea(node, conf, resize) {
...@@ -115,13 +115,13 @@ cc.Class({ ...@@ -115,13 +115,13 @@ cc.Class({
// const gameScale = dh / fh; // const gameScale = dh / fh;
// console.log(3333, conf.rect) // console.log(3333, conf.rect)
let width = this.getScaleValue(conf.rect.width) let width = this.getScaleValue(conf.rect.width)
let height = this.getScaleValue(conf.rect.height ) let height = this.getScaleValue(conf.rect.height)
let x = this.getScaleValue(conf.rect.x ) let x = this.getScaleValue(conf.rect.x)
// + conf.rect.width - conf.rect.width * node.anchorX // + conf.rect.width - conf.rect.width * node.anchorX
- cw / 2; - cw / 2;
let y = this.getScaleValue(-conf.rect.y ) let y = this.getScaleValue(-conf.rect.y)
// - conf.rect.height * node.anchorY // - conf.rect.height * node.anchorY
+this.getScaleValue(-conf.rect.height ) + this.getScaleValue(-conf.rect.height)
+ ch / 2; + ch / 2;
// let x = this.getScaleValue(conf.rect.x, conf.mapScale) // let x = this.getScaleValue(conf.rect.x, conf.mapScale)
...@@ -180,7 +180,7 @@ cc.Class({ ...@@ -180,7 +180,7 @@ cc.Class({
// return {x, y, width, height} // return {x, y, width, height}
}, },
// LIFE-CYCLE CALLBACKS: // LIFE-CYCLE CALLBACKS:
onLoad () { onLoad() {
// this.setNodeScale(); // this.setNodeScale();
...@@ -210,7 +210,7 @@ cc.Class({ ...@@ -210,7 +210,7 @@ cc.Class({
this.btnGroup.children.forEach(button => { this.btnGroup.children.forEach(button => {
this.modeNameMap[button.name] = button; this.modeNameMap[button.name] = button;
}); });
this.lrc =this.node.getChildByName('karaoke').getComponent('karaoke') this.lrc = this.node.getChildByName('karaoke').getComponent('karaoke')
// this.setCurrentMode(this.lrc.PLAY_MODE.MODE1); // this.setCurrentMode(this.lrc.PLAY_MODE.MODE1);
this.setPlayButtonStatus(this.BUTTON_STATUS.IDLE); this.setPlayButtonStatus(this.BUTTON_STATUS.IDLE);
...@@ -228,8 +228,8 @@ cc.Class({ ...@@ -228,8 +228,8 @@ cc.Class({
}); });
cc.director.on('GAME_DATA_FETCHED_sb_karaoke_cocos', (data) => { cc.director.on('GAME_DATA_FETCHED_sb_karaoke_cocos', (data) => {
const {width: dw, height: dh} = cc.view.getDesignResolutionSize(); const { width: dw, height: dh } = cc.view.getDesignResolutionSize();
const {width: fw, height: fh} = cc.view.getFrameSize(); const { width: fw, height: fh } = cc.view.getFrameSize();
this._gameScale = Math.min(dw / fw, dh / fh); this._gameScale = Math.min(dw / fw, dh / fh);
let sx = fw / dw; let sx = fw / dw;
...@@ -284,7 +284,7 @@ cc.Class({ ...@@ -284,7 +284,7 @@ cc.Class({
this.lrc.node.active = false; this.lrc.node.active = false;
} }
if(modeGroupRect){ if (modeGroupRect) {
this.setToRectArea(this.btnGroup, modeGroupRect); this.setToRectArea(this.btnGroup, modeGroupRect);
// this.btnGroup.x = modeArea.x; // this.btnGroup.x = modeArea.x;
// this.btnGroup.y = modeArea.y; // this.btnGroup.y = modeArea.y;
...@@ -357,13 +357,13 @@ cc.Class({ ...@@ -357,13 +357,13 @@ cc.Class({
// window.dispatchEvent(new CustomEvent('resize'), true) // window.dispatchEvent(new CustomEvent('resize'), true)
// window.dispatchEvent(new cc.Event.EventCustom('resize', true)) // window.dispatchEvent(new cc.Event.EventCustom('resize', true))
}, this); }, this);
cc.director.on('GAME_VIEW_DISPLAYED', function() { cc.director.on('GAME_VIEW_DISPLAYED', function () {
// this.karaoke.prepare(); // this.karaoke.prepare();
}, this); }, this);
window.gg =this window.gg = this
this.btnGroup.children.forEach(button => { this.btnGroup.children.forEach(button => {
button.actionStatus = this.BUTTON_STATUS.IDLE; button.actionStatus = this.BUTTON_STATUS.IDLE;
button.on(cc.Node.EventType.TOUCH_START, function(event) { button.on(cc.Node.EventType.TOUCH_START, function (event) {
const btn = event.currentTarget; const btn = event.currentTarget;
window.bb = btn; window.bb = btn;
this.buttonGroupChange(btn) this.buttonGroupChange(btn)
...@@ -373,7 +373,7 @@ cc.Class({ ...@@ -373,7 +373,7 @@ cc.Class({
; ;
}, },
setPlayButtonStatus(sts){ setPlayButtonStatus(sts) {
// this.lastButtonStateCache = this.BUTTON_STATUS.ACTIVE // this.lastButtonStateCache = this.BUTTON_STATUS.ACTIVE
if (this.actionButton.node.buttonStatus === sts) { if (this.actionButton.node.buttonStatus === sts) {
return return
...@@ -392,9 +392,9 @@ cc.Class({ ...@@ -392,9 +392,9 @@ cc.Class({
// console.log(1, curMode, sts); // console.log(1, curMode, sts);
}, },
toggleActionButtonStatus(){ toggleActionButtonStatus() {
let sts = this.BUTTON_STATUS.ACTIVE; let sts = this.BUTTON_STATUS.ACTIVE;
if(this.actionButton.node.buttonStatus == sts) { if (this.actionButton.node.buttonStatus == sts) {
sts = this.BUTTON_STATUS.IDLE; sts = this.BUTTON_STATUS.IDLE;
} }
// this.setPlayButtonStatus(sts); // this.setPlayButtonStatus(sts);
...@@ -423,13 +423,13 @@ cc.Class({ ...@@ -423,13 +423,13 @@ cc.Class({
// cc.tween(button.node).to(dur, {scale: 1}).start(); // cc.tween(button.node).to(dur, {scale: 1}).start();
} else { } else {
btn.actionStatus = this.BUTTON_STATUS.ACTIVE; btn.actionStatus = this.BUTTON_STATUS.ACTIVE;
cc.tween(button).to(dur, {scale: 1.2}).start() cc.tween(button).to(dur, { scale: 1.2 }).start()
this.changeBtnActive(button, true); this.changeBtnActive(button, true);
} }
return; return;
} }
button.actionStatus = this.BUTTON_STATUS.IDLE button.actionStatus = this.BUTTON_STATUS.IDLE
cc.tween(button).to(dur, {scale: 1}).start() cc.tween(button).to(dur, { scale: 1 }).start()
this.changeBtnActive(button, false); this.changeBtnActive(button, false);
}) })
...@@ -444,16 +444,15 @@ cc.Class({ ...@@ -444,16 +444,15 @@ cc.Class({
// console.log(event, index) // console.log(event, index)
// }, // },
start () { start() {
}, },
update (dt) { update(dt) {
if (this.lrc) { if (this.lrc) {
// const sts = this.lrc.getCurrentAudioState(); // const sts = this.lrc.getCurrentAudioState();
const sts = this.lrc.isCurrentAudioSourcePlaying(); const sts = this.lrc.isCurrentAudioSourcePlaying();
if (sts /*sts === cc.audioEngine.AudioState.PLAYING*/ ) { if (sts /*sts === cc.audioEngine.AudioState.PLAYING*/) {
this.setPlayButtonStatus(this.BUTTON_STATUS.ACTIVE); this.setPlayButtonStatus(this.BUTTON_STATUS.ACTIVE);
// this.lastButtonStateCache = this.BUTTON_STATUS.ACTIVE // this.lastButtonStateCache = this.BUTTON_STATUS.ACTIVE
} else { } else {
......
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