Commit 30648b97 authored by wjf's avatar wjf

l

parent ac47af6a
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
<body> <body>
<div style="margin: auto;width: 100%;height: 100%;" class="egret-player" data-entry-class="Main" <div style="margin: auto;width: 100%;height: 100%;" class="egret-player" data-entry-class="Main"
data-orientation="auto" data-scale-mode="showAll" data-frame-rate="60" data-content-width="750" data-orientation="auto" data-scale-mode="showAll" data-frame-rate="60" data-content-width="750"
data-content-height="1624" data-multi-fingered="2" data-show-fps="true" data-show-log="true" data-content-height="1624" data-multi-fingered="2" data-show-fps="false" data-show-log="true"
data-show-fps-style="x:0,y:0,size:12,textColor:0xffffff,bgAlpha:0.9"> data-show-fps-style="x:0,y:0,size:12,textColor:0xffffff,bgAlpha:0.9">
</div> </div>
......
...@@ -269,6 +269,9 @@ export default class MainBase extends eui.UILayer { ...@@ -269,6 +269,9 @@ export default class MainBase extends eui.UILayer {
for (var i = 1; i <= 11; i++) { for (var i = 1; i <= 11; i++) {
RES.getResAsync("hairballPiece" + i + "_png") RES.getResAsync("hairballPiece" + i + "_png")
} }
for (var i = 0; i <= 9; i++) {
RES.getResAsync("curScoreNum" + i + "_png")
}
var arr = [ var arr = [
"hairballDisBg", "hairballDisBg",
"brownBallFace", "brownBallFace",
......
...@@ -64,6 +64,7 @@ import { EleDownAni } from '../something/anis/EleDownAni'; ...@@ -64,6 +64,7 @@ import { EleDownAni } from '../something/anis/EleDownAni';
import { GameGuide } from '../something/uis/GameGuide'; import { GameGuide } from '../something/uis/GameGuide';
import { PropBtnCon } from '../something/uis/PropBtnCon'; import { PropBtnCon } from '../something/uis/PropBtnCon';
import { ChapterNum } from '../something/uis/ChapterNum'; import { ChapterNum } from '../something/uis/ChapterNum';
import { CurScoreNum } from '../something/uis/CurScoreNum';
const aniClass = { const aniClass = {
"BoomAni": BoomAni, "BoomAni": BoomAni,
...@@ -230,6 +231,8 @@ export default class MainScene extends Scene { ...@@ -230,6 +231,8 @@ export default class MainScene extends Scene {
this.chapter = (data && data.chapter) ? data.chapter : 1; this.chapter = (data && data.chapter) ? data.chapter : 1;
// this.chapter = 24; // this.chapter = 24;
this.chapterTxt.text = "第" + this.chapter + "关"; this.chapterTxt.text = "第" + this.chapter + "关";
this.removeChild(this.chapterTxt);
this.removeChild(this.scoreTxt);
//关卡数据 //关卡数据
this.chapterData = getChapterData(this.chapter); this.chapterData = getChapterData(this.chapter);
//初始化目标信息 //初始化目标信息
...@@ -318,9 +321,14 @@ export default class MainScene extends Scene { ...@@ -318,9 +321,14 @@ export default class MainScene extends Scene {
this.addChild(this.stepNumber); this.addChild(this.stepNumber);
//步数初始化 //步数初始化
this.steps = this.chapterData.stepCount; this.steps = this.chapterData.stepCount;
//当前分数
var curScoreNum = new CurScoreNum();
curScoreNum.x = 322;
curScoreNum.y = 92;
this.addChild(curScoreNum);
//分数进度条,托管 //分数进度条,托管
this.scoreProgress = new ScoreProgress(this.starProgress, this.scoreTxt, this.chapterData.starScores); this.scoreProgress = new ScoreProgress(this.starProgress, curScoreNum, this.chapterData.starScores);
this.scoreTxt.y -= 2;
//分数置0 //分数置0
this.score = 0; this.score = 0;
//地图生成 //地图生成
......
import { BitmapNumber } from "../class/BitmapNumber";
import { Tool } from "../Tool";
import { Pool } from "../Pool";
import { RecoverName } from "../enum/RecoverName";
/**
* 位图数字 目标元素数量
* 不管多少位,都按中间数字居中
* 暂不做通用,以后再说,否则回收问题
*/
export class CurScoreNum extends egret.DisplayObjectContainer {
/**
* 数字
*/
private _num: number;
get num(): number {
return this._num
}
set num(value: number) {
if (value == this._num) return;
this._num = value;
var arr = Tool.returnTO(value);
//位数从小到大add,
for (var i = 0; i < arr.length; i++) {
if (this.$children[i]) {
//先用完原先$children里的,不通用就没必要修改resName
this.$children[i]["num"] = arr[i];
} else {
//如果没有就
let o: BitmapNumber = Pool.takeOut(RecoverName.BITMAP_NUMBER);
if (!o) {
o = new BitmapNumber("curScoreNum");
} else {
o.reset("curScoreNum")
}
o.num = arr[i];
this.addChild(o)
}
}
//如果多了,去掉后面的,回收
if (this.$children.length > arr.length) {
//移除后序
for (var i = this.$children.length - 1; i >= arr.length; i--) {
let c = this.$children[i];
this.removeChild(c);
Pool.recover(RecoverName.BITMAP_NUMBER, c);
}
}
//居中适配
this.center()
}
constructor() {
super();
this.num = 0;
}
/**
* 居中位置
*/
center() {
//按顺序排,从右到左,
var len = this.$children.length;
var w = this.$children[0]["texture"].textureWidth - 4;
var right = len / 2 * w - w + len / 2 * w;
for (var i = 0; i < this.$children.length; i++) {
this.$children[i].x = right - w * i;
}
}
}
\ No newline at end of file
import { CurScoreNum } from "./CurScoreNum";
/** /**
* 分数条的托管类,不需要继承 * 分数条的托管类,不需要继承
...@@ -15,7 +16,7 @@ export class ScoreProgress { ...@@ -15,7 +16,7 @@ export class ScoreProgress {
star3: eui.Image; star3: eui.Image;
starProgress: eui.Image; starProgress: eui.Image;
scoreTxt: eui.Label; scoreTxt: CurScoreNum;
allScore: number; allScore: number;
private _score: number; private _score: number;
get score() { get score() {
...@@ -24,7 +25,7 @@ export class ScoreProgress { ...@@ -24,7 +25,7 @@ export class ScoreProgress {
set score(value: number) { set score(value: number) {
if (this._score == value) return if (this._score == value) return
this._score = value this._score = value
this.scoreTxt.text = Math.ceil(value) + ""; this.scoreTxt.num = Math.ceil(value);
var diss = [ var diss = [
188, 188,
446, 446,
...@@ -92,7 +93,7 @@ export class ScoreProgress { ...@@ -92,7 +93,7 @@ export class ScoreProgress {
* @param scoreTxt 托管 * @param scoreTxt 托管
* @param starScores * @param starScores
*/ */
constructor(starProgress: eui.Image, scoreTxt: eui.Label, starScores: number[]) { constructor(starProgress: eui.Image, scoreTxt: CurScoreNum, starScores: number[]) {
this.starProgress = starProgress; this.starProgress = starProgress;
this.scoreTxt = scoreTxt; this.scoreTxt = scoreTxt;
this.starScores = starScores; this.starScores = starScores;
......
...@@ -61,7 +61,7 @@ export class TargetNumber extends egret.DisplayObjectContainer { ...@@ -61,7 +61,7 @@ export class TargetNumber extends egret.DisplayObjectContainer {
center() { center() {
//按顺序排,从右到左, //按顺序排,从右到左,
var len = this.$children.length; var len = this.$children.length;
var w = this.$children[0]["texture"].textureWidth; var w = this.$children[0]["texture"].textureWidth-2;
var right = len / 2 * w - w; var right = len / 2 * w - w;
for (var i = 0; i < this.$children.length; i++) { for (var i = 0; i < this.$children.length; i++) {
this.$children[i].x = right - w * i; this.$children[i].x = right - w * 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