Commit e885e1ae authored by Tt's avatar Tt

阶段内容上传

parent a6cd520b
import { asyncDelay, onHomeworkFinish } from "../script/util";
import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent";
import Game, { GAME_STATE } from "./tool/Game";
import pg from "./tool/pg";
const { ccclass, property } = cc._decorator;
......@@ -25,161 +27,72 @@ export default class SceneComponent extends MyCocosSceneComponent {
// TODO 加载完成后的逻辑写在这里, 下面的代码仅供参考
this.initData();
this.initView();
this.initListener();
this.initEvent();
}
protected onDestroy(): void {
pg.event.clear();
}
_cantouch = null;
initData() {
Game.getIns().init(this.data);
Game.getIns().reset();
// 所有全局变量 默认都是null
this._cantouch = true;
}
private layout_start: cc.Node;
private audioId: any;
async initView() {
this.layout_start = pg.view.find(this, "layout_start");
initView() {
// this.initBg();
// this.initPic();
// this.initBtn();
// this.initIcon();
this.layout_start.active = true;
this.audioId = await pg.audio.playAudioByUrl(Game.getIns().question.audio);
if (this.audioId > -1 && Game.getIns().state == GAME_STATE.RUNNING) {
cc.audioEngine.stopAllEffects();
// pg.audio.stopAudio(this.audioId);
}
initBg() {
const bgNode = cc.find('Canvas/bg');
bgNode.scale = this._mapScaleMax;
}
initEvent() {
pg.view.touchOn(pg.view.find(this.layout_start, 'btn_start'), this.onTouchStart, this);
pic1 = null;
pic2 = null;
initPic() {
const canvas = cc.find('Canvas');
const maxW = canvas.width * 0.7;
this.getSprNodeByUrl(this.data.pic_url, (sprNode) => {
const picNode1 = sprNode;
picNode1.scale = maxW / picNode1.width;
picNode1.baseX = picNode1.x;
canvas.addChild(picNode1);
this.pic1 = picNode1;
const labelNode = new cc.Node();
labelNode.color = cc.Color.YELLOW;
const label = labelNode.addComponent(cc.Label);
label.string = this.data.text;
label.fontSize = 60;
label.lineHeight = 60;
label.font = cc.find('Canvas/res/font/BRLNSDB').getComponent('cc.Label').font;
picNode1.addChild(labelNode);
});
this.getSprNodeByUrl(this.data.pic_url_2, (sprNode) => {
const picNode2 = sprNode;
picNode2.scale = maxW / picNode2.width;
canvas.addChild(picNode2);
picNode2.x = canvas.width;
picNode2.baseX = picNode2.x;
this.pic2 = picNode2;
const labelNode = new cc.Node();
const label = labelNode.addComponent(cc.RichText);
const size = 60
label.font = cc.find('Canvas/res/font/BRLNSDB').getComponent(cc.Label).font;
label.string = `<outline color=#751e00 width=4><size=${size}><color=#ffffff>${this.data.text}</color></size></outline>`
label.lineHeight = size;
picNode2.addChild(labelNode);
});
}
initIcon() {
const iconNode = this.getSprNode('icon');
iconNode.zIndex = 5;
iconNode.anchorX = 1;
iconNode.anchorY = 1;
iconNode.parent = cc.find('Canvas');
iconNode.x = iconNode.parent.width / 2 - 10;
iconNode.y = iconNode.parent.height / 2 - 10;
iconNode.on(cc.Node.EventType.TOUCH_START, () => {
this.playAudioByUrl(this.data.audio_url);
pg.event.on("game_start", () => {
this.gameStart();
})
pg.event.on("game_time_over", () => {
// alert("game_time_over")
//这里的事件会发送的很早。但是我们需要等待动画执行完了之后再开始后续的内容
Game.getIns().addPage();
if (!Game.getIns().isOver) return pg.event.emit("game_start");
//发送给上端最后的数据
// alert("game_finish")
let player = { right: Game.getIns().player.score, error: Game.getIns().player.error }
let robot = { right: Game.getIns().robot.score, error: Game.getIns().robot.error }
if (Game.getIns().singleGame) {
onHomeworkFinish({ player })
} else {
onHomeworkFinish({ player, robot })
}
curPage = null;
initBtn() {
this.curPage = 0;
const bottomPart = cc.find('Canvas/bottomPart');
bottomPart.zIndex = 5; // 提高层级
bottomPart.x = bottomPart.parent.width / 2;
bottomPart.y = -bottomPart.parent.height / 2;
const leftBtnNode = bottomPart.getChildByName('btn_left');
//节点中添加了button组件 则可以添加click事件监听
leftBtnNode.on('click', () => {
if (!this._cantouch) {
return;
}
if (this.curPage == 0) {
return;
}
this.curPage = 0
this.leftMove();
this.playLocalAudio('btn');
})
const rightBtnNode = bottomPart.getChildByName('btn_right');
//节点中添加了button组件 则可以添加click事件监听
rightBtnNode.on('click', () => {
if (!this._cantouch) {
return;
}
if (this.curPage == 1) {
return;
onTouchStart() {
pg.audio.playLocalAudio(cc.find(`Canvas/res/audio/btn`));
pg.event.emit("game_start");
}
this.curPage = 1
this.rightMove();
// 游戏结束时需要调用这个方法通知系统作业完成
onHomeworkFinish();
this.playLocalAudio('btn');
})
gameStart() {
Game.getIns().state = GAME_STATE.RUNNING;
//游戏开始小鱼出现等等
this.layout_start.active = false;
if (this.audioId > -1 && Game.getIns().state != GAME_STATE.WAIT) {
cc.audioEngine.stopAllEffects();
// pg.audio.stopAudio(this.audioId);
}
leftMove() {
this._cantouch = false;
const len = this.pic1.parent.width;
cc.tween(this.pic1)
.to(1, { x: this.pic1.baseX }, { easing: 'cubicInOut' })
.start();
//开始
cc.tween(this.pic2)
.to(1, { x: this.pic2.baseX }, { easing: 'cubicInOut' })
.call(() => {
this._cantouch = true;
})
.start();
}
//根据数据随机热气球
rightMove() {
this._cantouch = false;
const len = this.pic1.parent.width;
cc.tween(this.pic1)
.to(1, { x: this.pic1.baseX - len }, { easing: 'cubicInOut' })
.start();
cc.tween(this.pic2)
.to(1, { x: this.pic2.baseX - len }, { easing: 'cubicInOut' })
.call(() => {
this._cantouch = true;
})
.start();
}
// update (dt) {},
initListener() {
//
}
......@@ -187,9 +100,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
const audio = cc.find(`Canvas/res/audio/${audioName}`).getComponent(cc.AudioSource);
return new Promise((resolve, reject) => {
const id = cc.audioEngine.playEffect(audio.clip, false);
cc.audioEngine.setFinishCallback(id, () => {
resolve(id);
});
cc.audioEngine.setFinishCallback(id, () => { resolve(id); });
})
}
}
{
"ver": "1.1.2",
"uuid": "24028cb8-b33b-4dac-bcd7-abfdd9c91d5c",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// 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";
const { ccclass, property } = cc._decorator;
export function getDegree(p1, p2) {
let vector = p2.sub(p1);
let degree = Math.atan(vector.y / vector.x) / Math.PI * 180;
if (vector.x >= 0) {
if (vector.y < 0) {
degree += 360;
}
} else {
if (vector.y > 0) {
degree += 180;
} else {
degree = 180 + degree;
}
}
return -(-degree + 90);//角度计算方法
}
@ccclass
export default class NewClass extends cc.Component {
@property(cc.Node)
res: cc.Node = null;
@property(cc.Node)
layout_player: cc.Node = null;
@property(cc.Node)
layout_robot: cc.Node = null;
@property(cc.Node)
item_left: cc.Node = null;
@property(cc.Node)
item_right: cc.Node = null;
onLoad() {
pg.event.on("game_start", () => {
this.gameStart();
})
}
private count: number;
private list: Option[];
private fishs: cc.Node[];
gameStart() {
//游戏开始。允许出鱼
let page = Game.getIns().getCurrentPage();
let list = page.optionList.concat();
list = JSON.parse(JSON.stringify(list));
list.sort((A, B) => { return Math.random() < 0.5 });
this.list = list;
this.count = 0;
this.lastCount = null;
this.robotFishTime = null;
this.fishs = [];
this.viewFishs = [];
this.touchFishs = [];
//根据顺序生成对应的鱼。
//顺序根据时间来进行跳动。当顺序跳动之后,就会产生新的鱼。
}
private lastCount: number;
private viewFishs: Option[];
private touchFishs: Option[];
getFishByCount(count) {
if (count <= this.lastCount) return null;
if (!this.list) return;
if (this.list.length == this.touchFishs.length) {
Game.getIns().state = GAME_STATE.OVER;
return pg.event.emit("game_time_over");
}
this.lastCount = count;
let list = this.list.filter((li) => {
return this.viewFishs.every(v => v.id != li.id) && this.touchFishs.every(t => t.id != li.id);
});
if (list.length == 0) return null;
let data = JSON.parse(JSON.stringify(list[count % list.length]));
data.fish.isLeft = Math.random() < 0.5;
let item_base = data.fish.isLeft ? this.item_left : this.item_right;
let item = cc.instantiate(item_base);
this.updateFish(item, data);
this.viewFishs.push(data);
return item;
}
private fishCount: number;
private lastY: number;
updateFish(item, data: Option) {
pg.view.touchOn(item, this.onTouchItem, this);
if (!this.fishCount) this.fishCount = 0;
let id = this.fishCount % 5 + 1;
this.fishCount++;
pg.view.visible(pg.view.find(item, 'fish/icon_fish1'), id == 1);
pg.view.visible(pg.view.find(item, 'fish/icon_fish2'), id == 2);
pg.view.visible(pg.view.find(item, 'fish/icon_fish3'), id == 3);
pg.view.visible(pg.view.find(item, 'fish/icon_fish4'), id == 4);
pg.view.visible(pg.view.find(item, 'fish/icon_fish5'), id == 5);
item.parent = this.node;
item.data = data;
data.fish.node = item;
//渲染部分
if (data.type == "txt") {
pg.view.visible(pg.view.find(item, 'layout_text'), true);
pg.view.visible(pg.view.find(item, 'layout_img'), false);
pg.view.setString(pg.view.find(item, "layout_text/text"), data.txt);
} else {
pg.view.visible(pg.view.find(item, 'layout_text'), false);
pg.view.visible(pg.view.find(item, 'layout_img'), true);
pg.view.setNetImg(pg.view.find(item, 'layout_img/img'), data.picUrl, { w: 118, h: 110 })
}
//x y 起始点 和终点 进行 随机
cc.Tween.stopAllByTarget(item);
if (data.fish.isLeft) {
//左往右
item.x = -(1334 / 2 + Math.random() * 200)
item.y = -290 + Math.random() * 400;//
cc.tween(item).to(10 + Math.random() * 10, { x: 1500 }).call(() => {
data.fish.isOut = FISH_OUT.OUT;
this.viewFishs = this.viewFishs.filter(v => v.id != data.id);
}).start();
} else {
//右往左
item.x = (1334 / 2) + Math.random() * 200;
item.y = -290 + Math.random() * 400;
cc.tween(item).to(10 + Math.random() * 10, { x: -1500 }).call(() => {
data.fish.isOut = FISH_OUT.OUT;
this.viewFishs = this.viewFishs.filter(v => v.id != data.id);
}).start();
}
}
private touching: boolean;
fishingRight(item, layout, data: Option) {
return new Promise((resolve, reject) => {
let wave = pg.view.find(layout, 'wave')
wave.active = true;
wave.angle = getDegree(cc.v2(item), cc.v2(layout).add(cc.v2(wave)));
let text = pg.view.find(layout, "text");
text.active = true;
data.audioUrl && pg.audio.playAudioByUrl(data.audioUrl)
cc.tween(item)
.to(1, { x: layout.x, y: layout.y + wave.y, scaleX: item.scaleX * 0.1, scaleY: item.scaleY * 0.1 }).call(() => {
//处理内容
data.fish.isOut = FISH_OUT.OUT;
wave.active = false;
text.active = false;
this.touching = false;
resolve('');
}).start();
});
}
fishingError(item, layout, data) {
return new Promise((resolve, reject) => {
pg.audio.playLocalAudio(pg.view.find(this.res, "audio/error"))
if (data.fish.isLeft) {
//左往右
cc.tween(item).to(3, { x: 1500 }).call(() => {
data.fish.isOut = FISH_OUT.OUT;
item.active = false;
setTimeout(() => { item.parent = null; }, 1000);
if (this.touchFishs.every(fish => fish.id != data.id)) {
resolve('');
}
}).start();
} else {
//右往左
cc.tween(item).to(3, { x: -1500 }).call(() => {
data.fish.isOut = FISH_OUT.OUT;
item.active = false;
setTimeout(() => { item.parent = null; }, 1000);
if (this.touchFishs.every(fish => fish.id != data.id)) {
resolve('');
}
}).start();
}
setTimeout(() => { this.touching = false; }, 500);
});
}
fishing(item, layout) {
return new Promise(async (resolve, reject) => {
let data = item.data;
//item停止动画并
cc.Tween.stopAllByTarget(item);
if (data.right) {
await this.fishingRight(item, layout, data);
} else {
await this.fishingError(item, layout, data);
}
this.touchFishs.push(data);
return resolve(data.right);
});
}
//开始点击 点击角色
async onTouchItem(e) {
if (this.touching) return;
this.touching = true;
let item = e.target;
let data = item.data;
if (this.touchFishs.some(fish => fish.id == data.id)) return;
if (data.fish.isOut != FISH_OUT.RUNNING) return;
data.fish.isOut = FISH_OUT.TOUCH;
let isRight = await this.fishing(item, this.layout_player);
isRight && Game.getIns().player.addScore();
!isRight && Game.getIns().player.addError();
}
//机器人随机钓鱼
private robotFishTime;
async onRobotFishing() {
this.layout_robot.active = !Game.getIns().singleGame;
if (!this.viewFishs) return;
if (Game.getIns().singleGame) return;
let nowTime = new Date().getTime();
if (!this.robotFishTime) this.robotFishTime = nowTime;
let time = 5000;//level来确定触发捕鱼的间隔时间。
if (nowTime - this.robotFishTime > time) {
let datas = this.viewFishs.filter(dat => dat.fish.node.x > -1334 / 2 && dat.fish.node.x < 1334 / 2);
let data = datas[Math.floor(Math.random() * datas.length)];
if (data.fish.isOut != FISH_OUT.RUNNING) return;
if (this.touchFishs.some(fish => fish.id == data.id)) return;
this.robotFishTime = nowTime - 1000;//-1000 动画时间
if (!data.right) return;
data.fish.isOut = FISH_OUT.TOUCH;
let isRight = await this.fishing(data.fish.node, this.layout_robot);
isRight && Game.getIns().robot.addScore();
!isRight && Game.getIns().player.addError();
}
}
get fishLen() {
if (!this.fishs) return 999;
let arr = this.fishs.filter(item => {
let data: Option = item.data;
return data.fish.isOut == FISH_OUT.RUNNING;
})
this.fishs = arr;
return this.fishs.length;
}
update(dt) {
if (Game.getIns().state != GAME_STATE.RUNNING) return;
if (this.fishLen < 5) this.count++;
this.onRobotFishing();
let fish = this.getFishByCount(this.count);
if (fish) this.fishs.push(fish);
}
}
{
"ver": "1.0.8",
"uuid": "7e5697f7-3598-4d41-ab4f-66aa53ffca4c",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// 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";
pg.event.clear();
const { ccclass, property } = cc._decorator;
@ccclass
export default class NewClass extends cc.Component {
// private btn_laba: cc.Node;
// private countDown: number = 999;
onLoad() {
this.initView();
this.initEvent();
}
private initEvent() {
pg.event.on("game_start", () => {
this.gameStart();
});
// pg.event.on("game_set_game_time", (count) => {
// this.countDown = count;
// });
// this.btn_laba.on(cc.Node.EventType.TOUCH_END, this.playLaba, this);
}
private gameStart() {
// this.countDown = Game.getIns().getCurrentPage().duration;
// this.playLaba();
}
private initView() {
// this.btn_laba = cc.find("btn_laba", this.node);
}
// private intervalId;
// private playLaba() {
// let btn_kaba2 = this.btn_laba.getChildByName("btn_laba2");
// let btn_kaba3 = this.btn_laba.getChildByName("btn_laba3");
// btn_kaba2.active = true;
// btn_kaba3.active = true;
// let count = 0;
// if (this.intervalId) clearInterval(this.intervalId);
// let stop = false;
// this.intervalId = setInterval(() => {
// count++;
// btn_kaba2.active = count % 3 == 1;
// btn_kaba3.active = count % 3 == 2;
// if (stop && count % 3 == 2) clearInterval(this.intervalId);
// }, 150)
// pg.audio.playAudioByUrl(Game.getIns().getCurrentPage().audio).then(() => { stop = true; })
// }
// private lastCount: number;
update(dt) {
if (Game.getIns().title) {
cc.find("bg_title/title", this.node).getComponent(cc.Label).string = Game.getIns().title;
}
// if (Game.getIns().state == GAME_STATE.OVER) return;
// if (Game.getIns().state == GAME_STATE.WAIT) return;
// if (this.countDown <= 0) {
// Game.getIns().state = GAME_STATE.OVER;
// pg.event.emit("game_time_over");
// return;
// }
// this.countDown = this.countDown - dt;
// if (this.countDown < 6) {
// let count = Math.floor(this.countDown);
// if (count != this.lastCount) {
// this.lastCount = count;
// if (this.lastCount == 1) {
// pg.audio.playLocalAudio(cc.find("bg_cd_red/audio_cd1", this.node))
// } else if (this.lastCount > 1) {
// pg.audio.playLocalAudio(cc.find("bg_cd_red/audio_cd", this.node))
// }
// }
// cc.find("bg_cd_red", this.node).active = true;
// cc.find("bg_cd_red/label_cd", this.node).getComponent(cc.Label).string = "" + parseInt("" + this.countDown);
// } else {
// cc.find("bg_cd_red", this.node).active = false;
// cc.find("bg_cd/label_cd", this.node).getComponent(cc.Label).string = "" + parseInt("" + this.countDown);
// }
}
}
\ No newline at end of file
{
"ver": "1.0.8",
"uuid": "6ea01498-81dd-4f71-88f5-b5224f5d7efe",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "6ac65a4c-4ac8-49e0-b66f-50e34324889c",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
export enum FISH_OUT {
RUNNING,
TOUCH,
CATCH,
ESCAP,
OUT
}
export class Fish {
public isOut: number;
public node: cc.Node;
public isLeft: boolean;//在左侧 向右运动
constructor() {
this.isOut = 0;
this.isLeft = Math.random() < 0.5;
}
}
export class Option {
public type;
public txt;
public picUrl;
public audioUrl;
public right: boolean;
public data;
public id: number;
public count: number;
public fish: Fish;
constructor(data, id) {
this.id = id;
this.data = data;
this.type = data.type;
this.txt = data.text;
this.picUrl = data.image;
this.audioUrl = data.audio;
this.right = data.right;
this.fish = new Fish();
}
}
export class Item {
public page;
public audio;
public duration;
public optionList;
constructor(data, page) {
this.audio = data.questionAudio;
this.duration = data.duration;
let id = 0;
this.optionList = data.options.map(o => {
return new Option(o, id++);
})
this.optionList.sort(function () {
return (0.5 - Math.random());
});
for (let i = 0; i < this.optionList.length; i++) {
this.optionList[i].count = i;
}
this.page = page;
}
}
class Role {
public score: number;
public error: number;
constructor() {
this.score = 0;
this.error = 0;
}
addScore(score: number = 1) {
this.score += score;
}
addError(score: number = 1) {
this.error += score;
}
}
export class Player extends Role {
constructor() {
super();
}
reset() {
}
}
export class Robot extends Role {
constructor() {
super();
}
reset() {
}
}
export enum GAME_STATE {
WAIT,
RUNNING,
OVER
}
export default class Game {
private static ins: Game;
public static getIns(): Game {
if (!Game.ins) Game.ins = new Game();
return Game.ins;
}
private data: any;
private lists: Array<Item>
public player: Player;
public robot: Robot;
public state: GAME_STATE;
constructor() {
this.start = false;
this.lists = [];
this.player = new Player();
this.robot = new Robot();
this.state = GAME_STATE.WAIT;
}
get len() {
return this.lists.length;
}
public singleGame: boolean;
public question: { text, audio };
public title: string;
public init(data) {
this.singleGame = !data.onlineFlg;
this.question = { text: data.questionText, audio: data.questionTextAudio };
this.title = data.title;
this.start = false;
this.lists = [];
this.data = data.questions;
}
public start: boolean;
public page: number;
reset() {
this.player.reset();
this.robot.reset();
this.page = 1;
this.start = true;
this.lists = [];
for (let i = 0; i < this.data.length; i++) {
let data = this.data[i];
this.lists.push(new Item(data, i + 1));
}
}
checkSuccess(arr: Option[]) {
let data = this.getCurrentPage();
let options = data.optionList.concat();
options.sort((A, B) => A.id - B.id)
for (let i = 0; i < options.length; i++) {
if (arr[i] && arr[i].id != options[i].id) {
return false;
}
}
return true;
}
getDataByPage(page): Item {
return this.lists.filter(li => li.page == page)[0]
}
getCurrentPage(): Item {
let page = this.page;
return this.lists.filter(li => li.page == page)[0]
}
getTotalPageNum() {
return this.lists.length;
}
getCurrentPageNum() {
return this.page;
}
addPage() {
this.page += 1;
}
get isOver() {
return this.page > this.lists.length;
}
}
\ No newline at end of file
{
"ver": "1.0.8",
"uuid": "5baeb71d-8316-4aad-ac1b-ed83e8dcbcc1",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.0.8",
"uuid": "f0076f6e-185d-42fd-b61b-698a3efa67ca",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
export const defaultData = {
"pic_url": "http://staging-teach.cdn.ireadabc.com/ed94332a503c31e0908bd4c6923a2665.png",
"pic_url_2": "http://staging-teach.cdn.ireadabc.com/5fb60317ade0195d35ad8034d5370a7f.png",
"text": "This is a test label.",
"audio_url": "http://staging-teach.cdn.ireadabc.com/f47f1d7b5c160fe1c59500d180346240.mp3"
onlineFlg: false, // 联机flg true联机版 false单机版
title: "标题文本", // 标题文本
questionText: "题目说明题目说明题目说明题目说明题目说明题目说明题目说明题目说明题目说明题目说明", // 题目说明
questionTextAudio: "http://staging-teach.cdn.ireadabc.com/b1019dcdb1f089ba9a65b71a1f52f67a.mp3", // 题目说明的语音
questions: [ // 题目,数组
{
questionAudio: "http://staging-teach.cdn.ireadabc.com/727a5af2f7ed99edb4a49d1126ecc9ca.mp3", // 题目音频
duration: 120, // 游戏倒计时(秒)
options: [ // 选项
{
type: "img",// 选项类型 img图片 txt文本
image: "http://staging-teach.cdn.ireadabc.com/03531e7ca2278b291da7d27bc1d60868.png", // 图片地址
audio: "http://staging-teach.cdn.ireadabc.com/727a5af2f7ed99edb4a49d1126ecc9ca.mp3", // 选项音频
text: "", // 选项类型为图片时,此选项没啥用
right: true // 这个选项是否是正确的
},
{
type: "text",// 选项类型 img图片 txt文本
image: "", // 选项类型为文本时,此选项没啥用
text: "asasdf", // 选项文本
audio: "http://staging-teach.cdn.ireadabc.com/727a5af2f7ed99edb4a49d1126ecc9ca.mp3",
right: true
},
{
image: "http://staging-teach.cdn.ireadabc.com/35bfd1d1342e1f2ea3db408afd072343.jpg",
audio: "",
type: "img",
text: "",
right: false
},
{
image: "",
audio: "",
type: "text",
text: "oliolioliooo",
right: false
}
]
},
{
questionAudio: "http://staging-teach.cdn.ireadabc.com/727a5af2f7ed99edb4a49d1126ecc9ca.mp3",
duration: 120, // 游戏倒计时(秒)
options: [
{
image: "http://staging-teach.cdn.ireadabc.com/03531e7ca2278b291da7d27bc1d60868.png",
audio: "http://staging-teach.cdn.ireadabc.com/727a5af2f7ed99edb4a49d1126ecc9ca.mp3",
type: "img",
text: "",
right: true
},
{
image: "",
audio: "http://staging-teach.cdn.ireadabc.com/727a5af2f7ed99edb4a49d1126ecc9ca.mp3",
type: "text",
text: "olio",
right: true
},
{
image: "http://staging-teach.cdn.ireadabc.com/35bfd1d1342e1f2ea3db408afd072343.jpg",
audio: "",
type: "img",
text: "",
right: false
},
{
image: "",
audio: "",
type: "text",
text: "oliolioliooo",
right: false
}
]
}
]
}
\ No newline at end of file
......@@ -411,12 +411,13 @@ export function showTrebleFirework(baseNode, rabbonList) {
showFireworks(right);
}
export function onHomeworkFinish() {
export function onHomeworkFinish(data) {
const middleLayer = cc.find('middleLayer');
if (middleLayer) {
const middleLayerComponent = middleLayer.getComponent('middleLayer');
if (middleLayerComponent.role == 'student') {
middleLayerComponent.onHomeworkFinish(() => { });
middleLayerComponent.onHomeworkFinish(() => { }, data);
}
} else {
console.log('onHomeworkFinish');
......
......@@ -4588,6 +4588,7 @@ declare namespace cc {
/** !#en Returns a normalized vector representing the forward direction (Z axis) of the node in world space.
!#zh 获取节点正前方(z 轴)面对的方向,返回值为世界坐标系下的归一化向量 */
forward: Vec3;
data: Option;
/**
@param name name
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