Commit 9d26ddce authored by Tt's avatar Tt

data引用错误调整

parent 7ea64f87
import Data from "../script/defaultData";
interface Item {
id: number;
text: string;
......@@ -14,6 +13,7 @@ export default class Game {
}
private lists: Array<any>
private nowStem: any;
private data: any;
public pause: boolean;
public isRobot: boolean;
public playerScore: number;
......@@ -22,8 +22,10 @@ export default class Game {
constructor() {
//
this.start = false;
this.data = null;
}
public init() {
public init(data) {
this.data = data;
this.start = false;
this.lists = null;
this.nowStem = null;
......@@ -36,7 +38,7 @@ export default class Game {
public start: boolean;
reset() {
this.start = true;
this.lists = JSON.parse(JSON.stringify(Data.list));
this.lists = JSON.parse(JSON.stringify(this.data.list));
this.pause = false;
this.isRobot = false;
this.playerScore = 0;
......
......@@ -48,7 +48,7 @@ export default class NewClass extends MyCocosSceneComponent {
this.log("test initData")
// 所有全局变量 默认都是null
this._cantouch = true;
Game.getIns().init();
Game.getIns().init(this.data);
//开始显示企鹅
}
initView() {
......
......@@ -105,11 +105,11 @@ export class MyCocosSceneComponent extends cc.Component {
});
}
log (str) {
log(str) {
const node = cc.find('middleLayer');
if(node){
if (node) {
node.getComponent('middleLayer').log(str);
}else{
} else {
cc.log(str);
}
}
......@@ -164,7 +164,7 @@ export class MyCocosSceneComponent extends cc.Component {
playAudioByUrl(audio_url, cb = null) {
if (audio_url) {
cc.assetManager.loadRemote(audio_url, (err, audioClip) => {
cc.assetManager.loadRemote(audio_url, (err, audioClip: any) => {
const audioId = cc.audioEngine.play(audioClip, false, 0.8);
if (cb) {
cc.audioEngine.setFinishCallback(audioId, () => {
......@@ -172,7 +172,7 @@ export class MyCocosSceneComponent extends cc.Component {
});
}
});
}else{
} else {
cb && cb();
}
}
......
export default {
export const defaultData = {
"list":
[
{
......
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