Commit 10f1dc9d authored by Master Q's avatar Master Q

背景音乐添加

parent 5342f43c
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
"firstLoginToday": true, "firstLoginToday": true,
"newUser": false, "newUser": false,
"shop": "FUSION", "shop": "FUSION",
"shopId": 10004 "shopId": 10004,
"completed": true
} }
} }
{
"success": true
}
\ No newline at end of file
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
"name": "balance_guidance" "name": "balance_guidance"
}, },
{ {
"keys": "back.png,back_jordan.png,comCloseBtn.png,com_light.png,toastBg.png,waitingBg.png,waitingRot.png,跳过按钮.png", "keys": "back.png,back_jordan.png,comCloseBtn.png,com_light.png,music-off.png,music-on.png,toastBg.png,waitingBg.png,waitingRot.png,跳过按钮.png",
"name": "common" "name": "common"
}, },
{ {
......
This diff is collapsed.
...@@ -49,7 +49,7 @@ export class GameOverPanel extends Panel { ...@@ -49,7 +49,7 @@ export class GameOverPanel extends Panel {
this.hidePanel() this.hidePanel()
// @ts-ignore // @ts-ignore
my && my.showToast({ my && my.showToast({
content: '很遗憾,谢谢参与' content: '很遗憾,您未中奖'
}) })
changeScene(GameOverScene, this.data) changeScene(GameOverScene, this.data)
} }
......
...@@ -54,8 +54,8 @@ export class GameOverScene extends Scene { ...@@ -54,8 +54,8 @@ export class GameOverScene extends Scene {
_s.addEventListener(FYGE.MouseEvent.CLICK, function() { _s.addEventListener(FYGE.MouseEvent.CLICK, function() {
this.btnDelay(this) this.btnDelay(this)
addData(8) addData(8)
// todo //@ts-ignore
console.log('回到主场') my && my.exit()
}, this) }, this)
_s.anchorTexture.set(0.5, 0.5) _s.anchorTexture.set(0.5, 0.5)
......
...@@ -12,6 +12,7 @@ import { RES } from '../../../module/RES'; ...@@ -12,6 +12,7 @@ import { RES } from '../../../module/RES';
import { sendTbNet, TbNetName } from '../../TaoBaoNet'; import { sendTbNet, TbNetName } from '../../TaoBaoNet';
import { GameOverScene } from '../GameOverScene/GameOverScene'; import { GameOverScene } from '../GameOverScene/GameOverScene';
import { GameOverPanel } from '../../panels/GameOverPanel'; import { GameOverPanel } from '../../panels/GameOverPanel';
import MusicBtn from '../../common/MusicBtn';
const Container = FYGE.Container const Container = FYGE.Container
const TEXT_ALIGN = FYGE.TEXT_ALIGN const TEXT_ALIGN = FYGE.TEXT_ALIGN
...@@ -114,15 +115,28 @@ export class GameScene extends MotionInitScene { ...@@ -114,15 +115,28 @@ export class GameScene extends MotionInitScene {
set score(n: number) { set score(n: number) {
this._score = n; this._score = n;
(this.scoreText || (this.scoreText = UI.Txt(this, '连续完成: ' + n, 40, '#111111', FYGE.TEXT_ALIGN.CENTER, layers.stageWidth, 0, layers.stageOffsetY + 200, true))).text = '连续完成: '+n if (!this.scoreText) {
this.scoreText = UI.Txt(this, '连续完成: ' + n, 40, '#111111', FYGE.TEXT_ALIGN.CENTER, layers.stageWidth, 0, layers.stageOffsetY + 200, true)
this.scoreText.mouseEnable = false
}
this.scoreText.text = '连续完成: '+n
} }
get score() { get score() {
return this._score return this._score
} }
musicStatus: boolean = true
musicBtn: FYGE.Button
async initUi() { async initUi() {
UI.Sp(this, this.isJordan ? 'back_jordan.png' : 'back.png') UI.Sp(this, this.isJordan ? 'back_jordan.png' : 'back.png')
this.musicBtn = UI.Btn(this, 'music-on.png', this.onMusicClick, this, 600, layers.stageOffsetY + 200)
FYGE.Tween.get(this.musicBtn, {loop: true})
.to({rotation: 360}, 5000)
this.musicBtn.anchorX = 30
this.musicBtn.anchorY = 30
this.score = 0 this.score = 0
...@@ -133,6 +147,10 @@ export class GameScene extends MotionInitScene { ...@@ -133,6 +147,10 @@ export class GameScene extends MotionInitScene {
DeviceMotion.instance.destory() DeviceMotion.instance.destory()
this.gameEle && this.gameEle.freeze() this.gameEle && this.gameEle.freeze()
FYGE.Tween.removeAllTweens() FYGE.Tween.removeAllTweens()
// 关闭背景
sendTbNet(TbNetName.openMusic, {
isOn: false
})
//@ts-ignore //@ts-ignore
this.onSubmit({ this.onSubmit({
id: Tools.globalData.startId, id: Tools.globalData.startId,
...@@ -144,6 +162,21 @@ export class GameScene extends MotionInitScene { ...@@ -144,6 +162,21 @@ export class GameScene extends MotionInitScene {
super.initUi() super.initUi()
} }
onMusicClick() {
this.musicStatus = !this.musicStatus
this.musicBtn.changeTexture(this.musicStatus ? RES.getRes('music-on.png') : RES.getRes('music-off.png'))
if (this.musicStatus) {
FYGE.Tween.get(this.musicBtn, {loop: true})
.to({rotation: 360}, 5000)
} else {
FYGE.Tween.removeTweens(this.musicBtn)
this.musicBtn.rotation = 0
}
sendTbNet(TbNetName.openMusic, {
isOn: this.musicStatus
})
}
initGame() { initGame() {
this.cdp.start() this.cdp.start()
...@@ -182,8 +215,11 @@ export class GameScene extends MotionInitScene { ...@@ -182,8 +215,11 @@ export class GameScene extends MotionInitScene {
this.cdp.start() this.cdp.start()
} }
descText: FYGE.TextField
initEvents() { initEvents() {
DeviceMotion.instance.notify((res) => {
(this.descText || (this.descText = UI.Txt(this, `alpha:${res.alpha.toFixed(2)}, beta: ${res.beta.toFixed(2)}, gamma: ${res.gamma.toFixed(2)}`, 32, '#111111', FYGE.TEXT_ALIGN.CENTER, layers.stageWidth, 0, layers.stageOffsetY + 100))).text = `alpha:${res.alpha.toFixed(2)}, beta: ${res.beta.toFixed(2)}, gamma: ${res.gamma.toFixed(2)}`
})
} }
removeEvents() { removeEvents() {
...@@ -201,7 +237,6 @@ export class GameEle extends Container { ...@@ -201,7 +237,6 @@ export class GameEle extends Container {
resisteAcc:number = GameCfg.resisteAcc // 摩擦力加速度 resisteAcc:number = GameCfg.resisteAcc // 摩擦力加速度
k: number // 旋转角度和和中心点距离的系数 k: number // 旋转角度和和中心点距离的系数
isIn: boolean // 是否在中心范围内 isIn: boolean // 是否在中心范围内
lastLen: number // 上一次的距离
fixedCenter: pos // 判断点坐标 fixedCenter: pos // 判断点坐标
finishFunc: Function // success callback finishFunc: Function // success callback
......
...@@ -38,8 +38,8 @@ export class NewGuyScene extends MotionInitScene { ...@@ -38,8 +38,8 @@ export class NewGuyScene extends MotionInitScene {
g1: FYGE.Sprite g1: FYGE.Sprite
initGame() { initGame() {
this.g1 = UI.Sp(this, 'guidance-t1.png', layers.stageCenterX, layers.stageCenterY + 400) // this.g1 = UI.Sp(this, 'guidance-t1.png', layers.stageCenterX, layers.stageCenterY + 400)
this.g1.anchorTexture.set(0.5, 0.5) // this.g1.anchorTexture.set(0.5, 0.5)
var e = this.addChild(new GameEle('p1.png', this.centerp, async () => { var e = this.addChild(new GameEle('p1.png', this.centerp, async () => {
const {success} = await sendTbNet(TbNetName.complteGuidance) const {success} = await sendTbNet(TbNetName.complteGuidance)
...@@ -48,7 +48,7 @@ export class NewGuyScene extends MotionInitScene { ...@@ -48,7 +48,7 @@ export class NewGuyScene extends MotionInitScene {
} }
shoot() { shoot() {
this.g1.visible = false this.g1 && (this.g1.visible = false)
this.desc && (this.desc.visible = false) this.desc && (this.desc.visible = false)
} }
......
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