Commit 7b478ad5 authored by zjz1994's avatar zjz1994

地图页优化暂存

parent 00d20b96
......@@ -12,35 +12,42 @@ export default class MapBottomPart extends ComponentBase {
getTxt(i): eui.BitmapLabel { return this[`txt${i}`]; }
start({repeatHeight,topHeight}) {
super.start();
const repeatCount =getRepeatCount();
for (let i = 0; i < MapBottomPart.LEVEL_NUMS; i++) {
const levelOrder = MapTopPart.LEVEL_NUMS + MapRpeatPart.LEVEL_NUMS * repeatCount + i +1;
this.getTxt(i).text = levelOrder + '';
}
for (let i = 0; i < MapBottomPart.LEVEL_NUMS; i++) {
const levelOrder = i + 1 + (window['total_level'] - MapBottomPart.LEVEL_NUMS);
if ( levelOrder > window['last_level']) {
setGray(this.getIcon(i));
this.getIcon(i).addEventListener(egret.TouchEvent.TOUCH_TAP, () => {
showToast('敬请期待更多关卡~');
}, this);
}
const icon = MapScene.iconHash[levelOrder] = this.getIcon(i);
this.removeChild(icon);
icon.show = ()=>{this.addChild(icon)};
icon.hide = ()=>{this.removeChild(icon)};
icon['nums'] = icon.getChildAt(0);
icon['bmptxt']=icon.getChildAt(1);
icon['mappart']=this;
for(var i=0;i<MapBottomPart.LEVEL_NUMS;i++){
const star = new MapStarComp();
star.loadSkin(); star.start();
MapScene.starHash[levelOrder] = star;
const icon = this.getIcon(i);
icon.addChild(star);
icon['visibleY'] = icon.y + topHeight + repeatHeight * repeatCount;
}
// const repeatCount =getRepeatCount();
// for (let i = 0; i < MapBottomPart.LEVEL_NUMS; i++) {
// const levelOrder = MapTopPart.LEVEL_NUMS + MapRpeatPart.LEVEL_NUMS * repeatCount + i +1;
// this.getTxt(i).text = levelOrder + '';
// }
// for (let i = 0; i < MapBottomPart.LEVEL_NUMS; i++) {
// const levelOrder = i + 1 + (window['total_level'] - MapBottomPart.LEVEL_NUMS);
// if ( levelOrder > window['last_level']) {
// setGray(this.getIcon(i));
// this.getIcon(i).addEventListener(egret.TouchEvent.TOUCH_TAP, () => {
// showToast('敬请期待更多关卡~');
// }, this);
// }
// const icon = MapScene.iconHash[levelOrder] = this.getIcon(i);
// this.removeChild(icon);
// icon.show = ()=>{this.addChild(icon)};
// icon.hide = ()=>{this.removeChild(icon)};
// icon['nums'] = icon.getChildAt(0);
// icon['bmptxt']=icon.getChildAt(1);
// icon['mappart']=this;
// const star = new MapStarComp();
// star.loadSkin(); star.start();
// MapScene.starHash[levelOrder] = star;
// icon.addChild(star);
// icon['visibleY'] = icon.y + topHeight + repeatHeight * repeatCount;
// }
}
getIcon(i) { return this[`icon${i}`]; }
......
......@@ -17,6 +17,23 @@ export default class MapRpeatPart extends ComponentBase {
start() {
super.start();
for(var i=0;i<MapRpeatPart.LEVEL_NUMS;i++){
const star = new MapStarComp();
star.loadSkin(); star.start();
const icon = this.getIcon(i);
icon.addChild(star);
icon.show = ()=>{this.addChild(icon)};
icon.hide = ()=>{this.removeChild(icon)};
icon['nums'] = icon.getChildAt(0);
icon['bmptxt']=icon.getChildAt(1);
icon.hide();
}
return;
for (let i = 0; i < MapRpeatPart.LEVEL_NUMS; i++) {
const levelOrder = MapTopPart.LEVEL_NUMS + this._index * MapRpeatPart.LEVEL_NUMS + i + 1;
......
......@@ -274,12 +274,21 @@ export default class MapScene extends Scene {
this.scrollMapy.push(smaph);
}
this.scrollMapy.push(smaph+mapbot_height);
var scrollheight = maptop_height+repeatnum*maprep_height+mapbot_height;
console.log("scroll--------height",scrollheight,this.scrollMapy);
this.scrollGroup.height = scrollheight;
var nowlevel = getHomeData().levels.length;
console.log("玩家level",nowlevel);
this.maptoppart.y = this.scrollMapy[0];
this.scrollGroup.addChild(this.maptoppart);
this.onemapreppart.y = this.scrollMapy[1];
this.scrollGroup.addChild(this.onemapreppart);
this.twomapreppart.y = this.scrollMapy[2];
this.scrollGroup.addChild(this.twomapreppart);
this.mapbotpart.y = this.scrollMapy[this.scrollMapy.length-2];
console.log('底部位置',this.mapbotpart.y);
this.scrollGroup.addChild(this.mapbotpart);
// console.log('地图数据-----',this._data);
// this.topPart = this._data.top;
......@@ -362,9 +371,13 @@ export default class MapScene extends Scene {
super();
this._data = data;
this.maptoppart = new MapTopPart();
this.maptoppart.loadSkin();
this.onemapreppart = new MapRpeatPart();
this.onemapreppart.loadSkin();
this.twomapreppart = new MapRpeatPart();
this.twomapreppart.loadSkin();
this.mapbotpart = new MapBottomPart();
this.mapbotpart.loadSkin();
this.once(egret.Event.ADDED_TO_STAGE,this.initMapScene,this);
}
......@@ -685,7 +698,7 @@ export default class MapScene extends Scene {
const offset = 0;
const y0 = this.scroll.viewport.scrollV + offset;
const y1 = this.stage.stageHeight + this.scroll.viewport.scrollV - offset;
console.log(y0, y1);
// console.log(y0, y1);
let count = 0;
for (const key in MapScene.iconHash) {
const icon = MapScene.iconHash[key];
......@@ -734,9 +747,55 @@ export default class MapScene extends Scene {
break;
}
}
for(var i3=lidx;i3<nidx;i3++){
var i3mapy = this.scrollMapy[i3];
var i3map:any;
//上下固定,只需要中间的调换位置
if(i3==0){
i3map = this.maptoppart;
}else if(i3==this.scrollMapy.length-1||i3==this.scrollMapy.length-2){
i3map = this.mapbotpart;
}else{
var joidx = i3%2;
//1对应onemapr,0对应twomapr
if(joidx==1){
i3map = this.onemapreppart;
}else{
i3map = this.twomapreppart;
}
if(i3map.y!=i3mapy){
i3map.y = i3mapy;
var i3startlevel = MapTopPart.LEVEL_NUMS+(i3-1)*MapRpeatPart.LEVEL_NUMS;
this.changePartLevelShow(i3map,i3startlevel);
console.log("局部显示",i3,i3mapy,i3startlevel);
}
}
// this.scrollGroup.addChild(i3map);
}
// console.log("局部显示",y0,y1,lidx,nidx,this.scrollMapy.length,this.scrollMapy[lidx],this.scrollMapy[nidx]);
}
console.log("局部显示",y0,y1,lidx,nidx,this.scrollMapy.length,this.scrollMapy[lidx],this.scrollMapy[nidx]);
/**
* 设置局部按钮显示
* @param mappart
* @param startlevel
*/
changePartLevelShow(mappart:any,startlevel:number){
var last_level = window['last_level'];
for(var i=0;i<MapRpeatPart.LEVEL_NUMS;i++){
const levelOrder = startlevel + i + 1;
let icon = mappart.getIcon(i);
icon.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.showToastQd);
mappart.getTxt(i).text = levelOrder + '';
if(levelOrder>last_level){
setGray(icon);
icon.addEventListener(egret.TouchEvent.TOUCH_TAP,this.showToastQd,this);
}
}
}
showToastQd(){
showToast('敬请期待更多关卡~');
}
// 添加图标
......
......@@ -7,24 +7,32 @@ export default class MapTopPart extends ComponentBase {
static LEVEL_NUMS = 8;
start() {
super.start();
for (let i = 0; i < MapTopPart.LEVEL_NUMS; i++) {
const levelOrder = i + 1;
const icon = MapScene.iconHash[levelOrder] = this.getIcon(i);
// const label:eui.BitmapLabel=icon.getChildAt(1) as eui.BitmapLabel;
for(var i=0;i<MapTopPart.LEVEL_NUMS;i++){
const star = new MapStarComp();
star.loadSkin(); star.start();
MapScene.starHash[levelOrder] = star;
const icon = this.getIcon(i);
icon.addChild(star);
icon['nums'] = icon.getChildAt(0);
icon['bmptxt']=icon.getChildAt(1);
this.removeChild(icon);icon.hide = ()=>{this.removeChild(icon)};
icon['mappart']=this;
icon.show = ()=>{this.addChild(icon)};
icon['visibleY'] = icon.y;
// console.log(icon['visibleY']);
}
// for (let i = 0; i < MapTopPart.LEVEL_NUMS; i++) {
// const levelOrder = i + 1;
// const icon = MapScene.iconHash[levelOrder] = this.getIcon(i);
// // const label:eui.BitmapLabel=icon.getChildAt(1) as eui.BitmapLabel;
// const star = new MapStarComp();
// star.loadSkin(); star.start();
// MapScene.starHash[levelOrder] = star;
// icon.addChild(star);
// icon['nums'] = icon.getChildAt(0);
// icon['bmptxt']=icon.getChildAt(1);
// this.removeChild(icon);icon.hide = ()=>{this.removeChild(icon)};
// icon['mappart']=this;
// icon.show = ()=>{this.addChild(icon)};
// icon['visibleY'] = icon.y;
// // console.log(icon['visibleY']);
// }
}
getIcon(i) { return this[`icon${i}`]; }
......
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