Commit 87c12ad1 authored by yu's avatar yu

背景音乐

parent 2776142d
{
"name": "弹弓动画1",
"imagePath": "dg1_tex.png",
"SubTexture": [
{
"name": "弹弓",
"x": 1,
"height": 264,
"y": 1,
"width": 202
},
{
"name": "大球",
"x": 175,
"height": 78,
"y": 267,
"width": 78
},
{
"name": "中间绳子1",
"x": 1,
"height": 164,
"y": 267,
"width": 172
},
{
"name": "绳子结",
"x": 1,
"height": 43,
"y": 433,
"width": 216
}
],
"height": 512,
"width": 256
}
\ No newline at end of file
......@@ -11,7 +11,7 @@
"height": 512,
"platformSettings": {},
"subMetas": {
"弹弓动画1_tex": {
"dg1_tex": {
"ver": "1.0.4",
"uuid": "08a64b0a-6aee-4b68-8c16-38af05d8b4e7",
"rawTextureUuid": "15c5ed8b-0432-4262-a107-a612e0ca88a3",
......
{
"name": "弹弓动画2",
"SubTexture": [
{
"name": "弹弓",
"x": 1,
"height": 264,
"y": 1,
"width": 202
},
{
"name": "大球",
"x": 175,
"height": 78,
"y": 267,
"width": 78
},
{
"name": "小球1",
"x": 205,
"height": 105,
"y": 1,
"width": 41
},
{
"name": "中间绳子1",
"x": 1,
"height": 164,
"y": 267,
"width": 172
},
{
"name": "绳子结",
"x": 1,
"height": 43,
"y": 433,
"width": 216
}
],
"imagePath": "dg2_tex.png",
"height": 512,
"width": 256
}
\ No newline at end of file
......@@ -11,7 +11,7 @@
"height": 512,
"platformSettings": {},
"subMetas": {
"弹弓动画2_tex": {
"dg2_tex": {
"ver": "1.0.4",
"uuid": "1fdf12c1-79ac-4cf9-b009-1070256eca69",
"rawTextureUuid": "1ce657fa-0585-4aef-ae0f-a5f55538a214",
......
{
"name": "弹弓动画3",
"SubTexture": [
{
"name": "弹弓",
"x": 1,
"height": 264,
"y": 1,
"width": 202
},
{
"name": "大球",
"x": 304,
"height": 78,
"y": 415,
"width": 78
},
{
"name": "小球2",
"x": 219,
"height": 90,
"y": 415,
"width": 83
},
{
"name": "左边绳子1",
"x": 1,
"height": 146,
"y": 267,
"width": 233
},
{
"name": "绳子结",
"x": 1,
"height": 43,
"y": 415,
"width": 216
}
],
"imagePath": "dg3_tex.png",
"height": 512,
"width": 512
}
\ No newline at end of file
......@@ -11,7 +11,7 @@
"height": 512,
"platformSettings": {},
"subMetas": {
"弹弓动画3_tex": {
"dg3_tex": {
"ver": "1.0.4",
"uuid": "e5af6e59-1365-4924-b0e5-9a92f4f6fdb6",
"rawTextureUuid": "d5fa8d39-5895-4a51-bd13-ff6a0cae74e2",
......
{"name":"弹弓动画1","imagePath":"弹弓动画1_tex.png","SubTexture":[{"name":"弹弓","x":1,"height":264,"y":1,"width":202},{"name":"大球","x":175,"height":78,"y":267,"width":78},{"name":"中间绳子1","x":1,"height":164,"y":267,"width":172},{"name":"绳子结","x":1,"height":43,"y":433,"width":216}],"height":512,"width":256}
\ No newline at end of file
{"name":"弹弓动画2","SubTexture":[{"name":"弹弓","x":1,"height":264,"y":1,"width":202},{"name":"大球","x":175,"height":78,"y":267,"width":78},{"name":"小球1","x":205,"height":105,"y":1,"width":41},{"name":"中间绳子1","x":1,"height":164,"y":267,"width":172},{"name":"绳子结","x":1,"height":43,"y":433,"width":216}],"imagePath":"弹弓动画2_tex.png","height":512,"width":256}
\ No newline at end of file
{"name":"弹弓动画3","SubTexture":[{"name":"弹弓","x":1,"height":264,"y":1,"width":202},{"name":"大球","x":304,"height":78,"y":415,"width":78},{"name":"小球2","x":219,"height":90,"y":415,"width":83},{"name":"左边绳子1","x":1,"height":146,"y":267,"width":233},{"name":"绳子结","x":1,"height":43,"y":415,"width":216}],"imagePath":"弹弓动画3_tex.png","height":512,"width":512}
\ No newline at end of file
This diff is collapsed.
import { asyncDelay, onHomeworkFinish } from "../script/util";
import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent";
import Game, { FISH_OUT, GAME_STATE, Option } from "./tool/Game";
import pg from "./tool/pg";
import { asyncDelay, onHomeworkFinish } from "../script/util_fireballoon";
import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent_fireballoon";
import Game, { FISH_OUT, GAME_STATE, Option } from "./tool/Game_fireballoon";
import pg from "./tool/pg_fireballoon";
const { ccclass, property } = cc._decorator;
......@@ -83,6 +83,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
item_gun: cc.Node = null;
@property(cc.Node)
bg_countdown: cc.Node = null;
@property(cc.Node)
btn_audio_off: cc.Node = null;
@property(cc.Node)
btn_audio_on: cc.Node = null;
@property(cc.Node)
item_left: cc.Node = null;
......@@ -99,6 +103,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
private layout_start: cc.Node;
private audioId: any;
private isPlayBgAudio: boolean;
private countDown: number = 999999;
private timeCount: number;
private startCount = 15;
......@@ -121,11 +126,19 @@ export default class SceneComponent extends MyCocosSceneComponent {
touch.on(cc.Node.EventType.TOUCH_END, () => {
cc.audioEngine.stopAllEffects();
pg.audio.stopAudio(this.audioId);
pg.audio.playAudioByUrl(Game.getIns().question.audio);
pg.audio.playAudioByUrl(Game.getIns().question.audio).then((audioId) => {
this.audioId = audioId;
if (audioId > -1 && Game.getIns().state == GAME_STATE.RUNNING) pg.audio.stopAudio(audioId);
});
})
if (Game.getIns().bgAudio || Game.getIns().bgAudio != "") {
this.btn_audio_on.active = true;
}
}
initEvent() {
pg.view.touchOn(pg.view.find(this.layout_start, 'btn_start'), this.onTouchStart, this);
this.btn_audio_off.on(cc.Node.EventType.TOUCH_END, this.onAudioOff, this);
this.btn_audio_on.on(cc.Node.EventType.TOUCH_END, this.onAudioOn, this);
pg.event.on("game_start", () => {
this.gameStart();
......@@ -152,10 +165,30 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
onTouchStart() {
pg.audio.playLocalAudio(cc.find(`Canvas/res/audio/btn`));
pg.audio.playBgAudioByUrl(Game.getIns().bgAudio);
pg.event.emit("game_start");
}
private onAudioOn() {
this.btn_audio_off.active = true;
this.btn_audio_on.active = false;
this.isPlayBgAudio = false;
this.stopBgAudio();
}
private onAudioOff() {
this.btn_audio_on.active = true;
this.btn_audio_off.active = false;
this.isPlayBgAudio = true;
this.playBgAudio();
}
private playBgAudio() {
if (!this.isPlayBgAudio) return;
cc.audioEngine.resumeMusic();
}
private stopBgAudio() {
cc.audioEngine.pauseMusic();
}
private count: number;
private list: Option[];
private fishs: cc.Node[];
......@@ -166,7 +199,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
//游戏开始小鱼出现等等
this.layout_start.active = false;
if (this.audioId > -1 && Game.getIns().state != GAME_STATE.WAIT) {
cc.audioEngine.stopAllEffects();
// cc.audioEngine.stopAllEffects();
pg.audio.stopAudio(this.audioId);
}
//开始
......@@ -557,7 +590,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
btn_start.active = false;
btn_stop.active = true;
ske.getComponent(dragonBones.ArmatureDisplay).timeScale = 1;
cc.audioEngine.stopAllEffects();
// cc.audioEngine.stopAllEffects();
this.bg_countdown.active = true;
this.countDown = this.startCount;
this.countDown = this.touchData.time || this.startCount; //this.startCount;
......@@ -781,3 +814,4 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
......@@ -5,8 +5,8 @@
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
import Game, { FISH_OUT, GAME_STATE, Option } from "../tool/Game";
import pg from "../tool/pg";
import Game, { FISH_OUT, GAME_STATE, Option } from "../tool/Game_fireballoon";
import pg from "../tool/pg_fireballoon";
const { ccclass, property } = cc._decorator;
......@@ -249,3 +249,4 @@ export default class NewClass extends cc.Component {
if (fish) this.fishs.push(fish);
}
}
......@@ -5,8 +5,8 @@
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
import Game, { GAME_STATE } from "../tool/Game";
import pg from "../tool/pg";
import Game, { GAME_STATE } from "../tool/Game_fireballoon";
import pg from "../tool/pg_fireballoon";
pg.event.clear();
const { ccclass, property } = cc._decorator;
......@@ -87,4 +87,4 @@ export default class NewClass extends cc.Component {
// cc.find("bg_cd/label_cd", this.node).getComponent(cc.Label).string = "" + parseInt("" + this.countDown);
// }
}
}
\ No newline at end of file
}
......@@ -139,12 +139,14 @@ export default class Game {
public singleGame: boolean;
public question: { text, audio };
public title: string;
public bgAudio: string;
public questionText: string;
public init(data) {
this.singleGame = !data.onlineFlg;
this.question = { text: data.questionText, audio: data.questionTextAudio };
this.title = data.title;
this.questionText = data.questionText;
this.bgAudio = data.bgAduio || "";
this.start = false;
this.lists = [];
this.data = data.questions;
......@@ -198,4 +200,4 @@ export default class Game {
get isOver() {
return this.page > this.lists.length;
}
}
\ No newline at end of file
}
......@@ -532,7 +532,7 @@ let pg = {
});
},
stopAudio(audioId) {
if (!audioId) return;
if (audioId < 0) return;
cc.audioEngine.stopEffect(audioId);
},
playAudio(audioClip, cb = null) {
......@@ -547,6 +547,19 @@ let pg = {
return audioId;
}
},
playBgAudioByUrl(audio_url, cb = null, loadCb = null) {
return new Promise((resolve, reject) => {
if (!audio_url) return resolve(null);
cc.assetManager.loadRemote(audio_url, (err, audioClip: any) => {
const audioId = cc.audioEngine.playMusic(audioClip, true);
cc.audioEngine.setFinishCallback(audioId, () => {
cb && cb();
});
loadCb && loadCb(audioId);
resolve(audioId);
});
});
},
playLocalAudio(audio: cc.Node) {
return new Promise((resolve, reject) => {
const id = cc.audioEngine.playEffect(audio.getComponent(cc.AudioSource).clip, false);
......@@ -589,4 +602,4 @@ let pg = {
},
event: Emitter.getInstance()
};
export default pg;
\ No newline at end of file
export default pg;
import { defaultData } from "../script/defaultData";
import { defaultData } from "../script/defaultData_fireballoon";
export class MyCocosSceneComponent extends cc.Component {
......@@ -176,4 +176,4 @@ export class MyCocosSceneComponent extends cc.Component {
cb && cb();
}
}
}
\ No newline at end of file
}
......@@ -2,6 +2,7 @@ export const defaultData = {
"title": "热气球大战",
"questionText": "可恶的小偷将魔法卡牌藏在热气球里,准备偷走!快击落热气球,夺回魔法卡牌。游戏开始,请点击弹弓,发射小球,击落热气球,魔法卡牌就会掉落下来。请仔细观察魔法卡牌,并大声说出魔法咒语。魔法咒语正确,你将获得该张魔法卡牌。游戏结束后,根据获得的魔法卡牌数量,你将获得相应的能量石奖励!开始挑战吧!",
"questionTextAudio": "https://staging-teach.cdn.ireadabc.com/3152e0ea17b07406a002b2c05028b0cc.mp3",
"bgAduio": "https://staging-teach.cdn.ireadabc.com/ed84c18cc5f696ceaaf488ff98c228fe_l.mp3",
"questions": [
{
"options": [
......@@ -82,4 +83,4 @@ export const defaultData = {
]
}
]
}
\ No newline at end of file
}
......@@ -422,4 +422,4 @@ export function onHomeworkFinish(data) {
} else {
console.log('onHomeworkFinish');
}
}
\ No newline at end of file
}
......@@ -11,7 +11,7 @@
"height": 336,
"platformSettings": {},
"subMetas": {
"1orange": {
"1orange_fireballoon": {
"ver": "1.0.4",
"uuid": "17487daf-3875-48b5-9884-fb0a0bccd3d5",
"rawTextureUuid": "9eb89c84-1cc7-42c9-ac57-df702f77dcef",
......
......@@ -11,7 +11,7 @@
"height": 720,
"platformSettings": {},
"subMetas": {
"bg": {
"bg_fireballoon": {
"ver": "1.0.4",
"uuid": "057d9312-06e8-44d1-9379-6aafe1869ff0",
"rawTextureUuid": "f37041cd-c3f7-4b78-8f8e-3bce4538eda7",
......
......@@ -11,7 +11,7 @@
"height": 67,
"platformSettings": {},
"subMetas": {
"btn_left": {
"btn_left_fireballoon": {
"ver": "1.0.4",
"uuid": "712039b7-4413-4fad-bc38-18899d62f771",
"rawTextureUuid": "af5ba431-34f8-4dd7-9275-364bf1e11142",
......
......@@ -11,7 +11,7 @@
"height": 67,
"platformSettings": {},
"subMetas": {
"btn_right": {
"btn_right_fireballoon": {
"ver": "1.0.4",
"uuid": "0b0af429-d3cb-414c-ad5c-f984d5f82b72",
"rawTextureUuid": "39c9e77b-9a0e-4db2-81e4-7edd3affe3a1",
......
......@@ -11,7 +11,7 @@
"height": 245,
"platformSettings": {},
"subMetas": {
"bg_could": {
"bg_could_fireballoon": {
"ver": "1.0.4",
"uuid": "762b0e4d-bbfd-4700-9ae7-691d216330f9",
"rawTextureUuid": "04b08235-81e3-4942-b92c-66f42fdf119a",
......
......@@ -11,7 +11,7 @@
"height": 88,
"platformSettings": {},
"subMetas": {
"bg_countdown": {
"bg_countdown_fireballoon": {
"ver": "1.0.4",
"uuid": "724e7031-49c9-47d3-883d-44d4da25987d",
"rawTextureUuid": "bd10ee69-6e5b-410b-99e7-41913ddd99a6",
......
......@@ -11,7 +11,7 @@
"height": 750,
"platformSettings": {},
"subMetas": {
"bg": {
"bg_fireballoon": {
"ver": "1.0.4",
"uuid": "53f94ea8-79b2-4d4a-bc99-a4e0c6402d85",
"rawTextureUuid": "45dc4a01-7202-4c63-a29a-2373ae30f779",
......
......@@ -11,7 +11,7 @@
"height": 380,
"platformSettings": {},
"subMetas": {
"bg_instructions": {
"bg_instructions_fireballoon": {
"ver": "1.0.4",
"uuid": "63c82d2c-6b6c-4b82-9b06-62b9c3ea423d",
"rawTextureUuid": "0624005a-6305-4009-8b04-e7b919699e87",
......
......@@ -11,7 +11,7 @@
"height": 137,
"platformSettings": {},
"subMetas": {
"btn_restart": {
"btn_restart_fireballoon": {
"ver": "1.0.4",
"uuid": "3cf25abd-faab-48b6-9128-d7030c57db67",
"rawTextureUuid": "4cd0c381-4adb-47cc-88d1-898499087172",
......
......@@ -11,7 +11,7 @@
"height": 137,
"platformSettings": {},
"subMetas": {
"btn_start1": {
"btn_start1_fireballoon": {
"ver": "1.0.4",
"uuid": "78733786-a84c-4caf-b3c9-789817838917",
"rawTextureUuid": "7fe56fa8-0406-48f8-b97d-ec7fc477d3af",
......
......@@ -11,7 +11,7 @@
"height": 100,
"platformSettings": {},
"subMetas": {
"btn_start2": {
"btn_start2_fireballoon": {
"ver": "1.0.4",
"uuid": "8c5a64e9-0660-4ee5-bf99-069565384ea4",
"rawTextureUuid": "5497ae81-1dd4-43a1-bbba-20971b247f42",
......
......@@ -11,7 +11,7 @@
"height": 100,
"platformSettings": {},
"subMetas": {
"btn_stop": {
"btn_stop_fireballoon": {
"ver": "1.0.4",
"uuid": "91e9a4cf-fb1e-45d2-a365-991574d1d343",
"rawTextureUuid": "00495059-484f-4797-93aa-84ffc7e7ae14",
......
......@@ -11,7 +11,7 @@
"height": 78,
"platformSettings": {},
"subMetas": {
"ball": {
"ball_fireballoon": {
"ver": "1.0.4",
"uuid": "14553acc-97f4-4d49-8ebf-26d02151efe9",
"rawTextureUuid": "64a82e7b-f5e8-4fe6-955b-9c8c9e24b4e2",
......
......@@ -11,7 +11,7 @@
"height": 201,
"platformSettings": {},
"subMetas": {
"body": {
"body_fireballoon": {
"ver": "1.0.4",
"uuid": "a5924bf6-ef1a-4e51-a648-e17a26484cf0",
"rawTextureUuid": "72a61d88-6a63-4b7a-92cd-8fe7a667ecfc",
......
{
"name": "弹弓动画1",
"SubTexture": [
{
"name": "中间绳子1",
"x": 1,
"height": 164,
"y": 1,
"width": 172
}
],
"imagePath": "dg1_tex.png",
"height": 256,
"width": 256
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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