Commit e41f742d authored by Tt's avatar Tt

基础整理

parent 1a487a13
This diff is collapsed.
......@@ -35,6 +35,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
async onLoadEnd() {
// TODO 加载完成后的逻辑写在这里, 下面的代码仅供参考
this.initSysteam();
this.initData();
this.initView();
this.initListener();
......@@ -44,9 +45,20 @@ export default class SceneComponent extends MyCocosSceneComponent {
})
pg.event.emit('npc_layer_back_init', this.data)
}
initSysteam() {
console.log("调用竖版")
if (cc.sys.isNative && cc.sys.os == cc.sys.OS_IOS) {
courseware && courseware.onConfigurationPortrait()
} else {
courseware && courseware.onConfigurationPortrait()
}
}
protected onDestroy(): void {
pg.event.clear();
courseware.onConfigurationLandscape()
}
_cantouch = null;
private item_question: cc.Node
//题目id
private currentId: number
//总时间时间
......@@ -59,6 +71,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
private layer_game: cc.Node;
// 准备开始
private layout_begin: cc.Node;
private layout_question: cc.Node;
initData() {
// 所有全局变量 默认都是null
this._cantouch = true;
......@@ -67,11 +80,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
initView() {
// 取对象
/* this.item_question = pg.view.find(this, 'item_question'); */
this.layer_game = pg.view.find(this, 'layer_game');
this.layout_begin = pg.view.find(this.layer_game, 'layout_begin');
this.layout_question = pg.view.find(this.layer_game, 'layout_question');
pg.view.visible(pg.view.find(this.layer_game, 'countdown/countdown1'), true);
pg.view.visible(pg.view.find(this.layer_game, 'countdown/countdown2'), false);
let item_question = pg.view.find(this, 'layer_game/item_question');
pg.view.visible(item_question, false);
}
initListener() {
......@@ -140,6 +155,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
//----------------------Question------------------------------------
private currentTime: number;
private currentItemQuestion: cc.Node;
private nextItemQuestion: cc.Node;
startQuestion() {
// 游戏所需的初始化数据
this.currentId = 0
......@@ -149,15 +166,28 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.right = 0
this.gameStart = true;
this.state = State.Recording;
this.currentItemQuestion = this.createQuestionItem(cc.v2(0, 50));
this.updateQuestion();
this.updateProgress();
}
createQuestionItem(pos) {
let item_question = pg.view.find(this, 'layer_game/item_question');
let clone_question = pg.view.clone(item_question);
clone_question.active = true;
clone_question.x = pos.x;
clone_question.y = pos.y;
this.layout_question.addChild(clone_question);
return clone_question;
}
//题目
updateQuestion() {
let item_question = pg.view.find(this, 'layer_game/item_question');
let itemQuestion = this.currentItemQuestion;
let data = this.getCurrent();
pg.view.setNetImg(pg.view.find(item_question, "img"), data.image, { w: 700, h: 360 })
pg.view.setString(pg.view.find(item_question, "text"), data.text)
pg.view.setNetImg(pg.view.find(itemQuestion, "img"), data.image, { w: 700, h: 360 })
pg.view.setString(pg.view.find(itemQuestion, "text"), data.text)
}
//------------------------------Loop----------------------------------
......@@ -210,13 +240,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
//用户回答结果
checkRight(score) {
let isRight = score > 40;
let item_question = pg.view.find(this, 'layer_game/item_question');
/*
* answer 获取的用户答案
*/
//判断对错
let row = pg.view.find(this, 'layer_game/row');
item_question.children[2].active = true
let currentItemQuestion = this.currentItemQuestion;
let row = pg.view.find(currentItemQuestion, 'row');
currentItemQuestion.children[2].active = true
//正确
if (isRight) {
//正确后执行函数
......@@ -240,14 +270,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
hideAnswer() {
let item_question = pg.view.find(this, 'layer_game/item_question');
let row = pg.view.find(this, 'layer_game/row');
console.log("节点移出画面")
let currentItemQuestion = this.currentItemQuestion;
let row = pg.view.find(currentItemQuestion, 'row');
let right = pg.view.find(row, 'right');
let mistake = pg.view.find(row, 'mistake');
let text = pg.view.find(item_question, 'text');
right.active = false
mistake.active = false
text.active = false
}
//------------------------------Record----------------------------------
......
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