Commit 13e37af5 authored by Tt's avatar Tt

处理完成

parent 9f5f5457
{
"ver": "1.1.0",
"uuid": "e8443972-76cc-4af5-a2cc-60ae7616400e",
"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
const { ccclass, property } = cc._decorator;
@ccclass
export default class NewClass extends cc.Component {
private list: Array<{ img, name, id }>;
//TODO:入口方法
public setData(val) {
this.list = [val.left, val.right];
this.initView();
}
//TODO:点击事件
public onTouchItem(e) {
let data = e.target.data;
console.log(data);
let event = new cc.Event.EventCustom('page1_btn_click', true);
event.setUserData(data);
this.node.dispatchEvent(event);
}
private layout: cc.Node;
onLoad() {
this.layout = this.node.getChildByName("layout");
}
initView() {
let children = this.layout.children;
this.list.forEach((data, index) => {
let item = children[index];
this.updateItem(item, data);
})
}
updateItem(item: any, data) {
item.active = true;
item.data = data;
let icon = item.getChildByName("icon")
let bg = item.getChildByName("bg")
let title = item.getChildByName("title")
this.setNetImg(icon, data.img, { w: 320, h: 370 })
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");
let node = item.node ? item.node : item;
if (!url) {
if (node) node.active = false;
return console.log("图片更换失败,传入了错误的res");
}
if (!node) return console.log("图片更换失败,传入了错误的item");
if (node.net_url == url) return;
node.active = false;//
cc.loader.load({ url }, (err, texture) => {
if (err && !texture) return;
if (!cc.isValid(node)) return console.log("节点已销毁");
let nw = node.width = texture.width;
let nh = node.height = texture.height;
let component = node.getComponent(cc.Sprite);
let spriteFrame = new cc.SpriteFrame(texture);
component.spriteFrame = spriteFrame;
node.net_url = url;
if (!cc.isValid(node)) return console.log("节点已销毁");
if (!node) return console.log("节点已销毁");
if (w && h) {
let scaleX = w / nw;
let scaleY = h / nh;
let scale = scaleX <= scaleY ? scaleX : scaleY;
node.width = nw * scale;
node.height = nh * scale;
}
node.active = true;
resolve({ w: nw, h: nh });
});
})
}
}
{
"ver": "1.0.8",
"uuid": "903b7ebe-875c-48a3-8c84-8900b958913d",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.0.8",
"uuid": "98ef213a-d8ac-462b-902d-f2c81614be29",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.0.8",
"uuid": "7b1df84d-ee4f-4bd7-8a44-54adc211b413",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
// 新剧本地图页
export const defaultData = { export const defaultData = {
"pic_url": "http://staging-teach.cdn.ireadabc.com/ed94332a503c31e0908bd4c6923a2665.png", //左右两个
"pic_url_2": "http://staging-teach.cdn.ireadabc.com/5fb60317ade0195d35ad8034d5370a7f.png", left: {
"text": "This is a test label.", img: 'http://staging-teach.cdn.ireadabc.com/0d332cb2b167feb4204b1d77a6f02ed6.jpg',
"audio_url": "http://staging-teach.cdn.ireadabc.com/f47f1d7b5c160fe1c59500d180346240.mp3" name: '小红帽历险记',
} id: 1234,
\ No newline at end of file },
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,
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,
id: 1235,
}],
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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