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

style: format

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