Commit bbe9220d authored by liujiangnan's avatar liujiangnan

feat: 兼容多剧本

parent 914e24ee
This diff is collapsed.
......@@ -8,13 +8,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
addPreloadImage() {
// TODO 根据自己的配置预加载图片资源
this._imageResList.push({ url: this.data.pic_url });
this._imageResList.push({ url: this.data.pic_url_2 });
}
addPreloadAudio() {
// TODO 根据自己的配置预加载音频资源
this._audioResList.push({ url: this.data.audio_url });
}
addPreloadAnima() {
......@@ -52,10 +49,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
});
}
toPage1(testData = null) {
testData = { left: this.data.left, right: this.data.right };
this.page1.active = true;
this.page1.getComponent('page1').setData(testData)
this.page1.getComponent('page1').setData(this.data)
}
playLocalAudio(audioName) {
......
......@@ -12,7 +12,7 @@ export default class NewClass extends cc.Component {
private list: Array<{ img, name, id }>;
//TODO:入口方法
public setData(val) {
this.list = [val.left, val.right];
this.list = val;
this.initView();
}
//TODO:点击事件
......@@ -25,14 +25,25 @@ export default class NewClass extends cc.Component {
}
private layout: cc.Node;
private item: cc.Node;
onLoad() {
this.item = this.node.getChildByName("item");
this.item.active = false;
this.layout = this.node.getChildByName("layout");
}
initView() {
let children = this.layout.children;
this.list.forEach((data, index) => {
let item = children[index];
if (this.list.length < 3) {
this.layout = this.node.getChildByName("layout");
this.layout.width = this.list.length == 2 ? 880 : 440;
} else {
let scrollview = this.node.getChildByName("scrollview");
let view = scrollview.getChildByName("view");
this.layout = view.getChildByName("content");
}
this.list.forEach((data) => {
let item = cc.instantiate(this.item);
this.updateItem(item, data);
this.layout.addChild(item)
})
}
updateItem(item: any, data) {
......@@ -45,8 +56,6 @@ export default class NewClass extends cc.Component {
title.getComponent(cc.Label).string = data.name;
item.on(cc.Node.EventType.TOUCH_END, this.onTouchItem, this);
}
setNetImg(item, url, { w, h }) {
return new Promise((resolve, reject) => {
if (!item) return console.log("图片更换失败,传入了错误的item");
......
// 新剧本地图页
export const defaultData = {
//左右两个
left: {
export const defaultData = [
{
img: 'http://staging-teach.cdn.ireadabc.com/0d332cb2b167feb4204b1d77a6f02ed6.jpg',
name: '小红帽历险记',
id: 1234,
},
right: {
},{
img: 'http://staging-teach.cdn.ireadabc.com/0d332cb2b167feb4204b1d77a6f02ed6.jpg',
name: '大红帽历险记',
id: 1235,
},
//固定3个
eventList: [{
},{
img: 'http://staging-teach.cdn.ireadabc.com/0d332cb2b167feb4204b1d77a6f02ed6.jpg',
name: '小红帽历险记',
totalIcon: 0,
locked: false,
id: 1234,
}, {
img: 'http://staging-teach.cdn.ireadabc.com/0d332cb2b167feb4204b1d77a6f02ed6.jpg',
name: '中红帽历险记',
totalIcon: 100,
locked: false,
name: '三红帽历险记',
id: 1235,
}, {
img: 'http://staging-teach.cdn.ireadabc.com/0d332cb2b167feb4204b1d77a6f02ed6.jpg',
name: '大红帽历险记',
totalIcon: 100,
locked: true,
id: 1236,
}],
//游戏列表
gameList: [{
},{
img: 'http://staging-teach.cdn.ireadabc.com/0d332cb2b167feb4204b1d77a6f02ed6.jpg',
name: '小红帽历险记1',
locked: false,
id: 1231,
}, {
img: 'http://staging-teach.cdn.ireadabc.com/0d332cb2b167feb4204b1d77a6f02ed6.jpg',
name: '小红帽历险记2',
locked: false,
id: 1232,
}, {
img: 'http://staging-teach.cdn.ireadabc.com/0d332cb2b167feb4204b1d77a6f02ed6.jpg',
name: '小红帽历险记3',
locked: false,
id: 1233,
}, {
img: 'http://staging-teach.cdn.ireadabc.com/0d332cb2b167feb4204b1d77a6f02ed6.jpg',
name: '小红帽历险记4',
locked: false,
id: 1234,
}, {
img: 'http://staging-teach.cdn.ireadabc.com/0d332cb2b167feb4204b1d77a6f02ed6.jpg',
name: '小红帽历险记5',
locked: false,
name: '四红帽历险记',
id: 1235,
}],
}
},
]
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