Commit 7f4b8a8b authored by 邱旭's avatar 邱旭

erge branch 'dev' of http://gitlab2.dui88.com/wanghongyuan/xiaoxiaole into dev

parents 87848443 a98ac94a
......@@ -41,7 +41,7 @@
<body>
<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-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">
</div>
......
......@@ -269,6 +269,9 @@ export default class MainBase extends eui.UILayer {
for (var i = 1; i <= 11; i++) {
RES.getResAsync("hairballPiece" + i + "_png")
}
for (var i = 0; i <= 9; i++) {
RES.getResAsync("curScoreNum" + i + "_png")
}
var arr = [
"hairballDisBg",
"brownBallFace",
......
......@@ -64,6 +64,7 @@ import { EleDownAni } from '../something/anis/EleDownAni';
import { GameGuide } from '../something/uis/GameGuide';
import { PropBtnCon } from '../something/uis/PropBtnCon';
import { ChapterNum } from '../something/uis/ChapterNum';
import { CurScoreNum } from '../something/uis/CurScoreNum';
const aniClass = {
"BoomAni": BoomAni,
......@@ -230,6 +231,8 @@ export default class MainScene extends Scene {
this.chapter = (data && data.chapter) ? data.chapter : 1;
// this.chapter = 24;
this.chapterTxt.text = "第" + this.chapter + "关";
this.removeChild(this.chapterTxt);
this.removeChild(this.scoreTxt);
//关卡数据
this.chapterData = getChapterData(this.chapter);
//初始化目标信息
......@@ -318,9 +321,14 @@ export default class MainScene extends Scene {
this.addChild(this.stepNumber);
//步数初始化
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.scoreTxt.y -= 2;
this.scoreProgress = new ScoreProgress(this.starProgress, curScoreNum, this.chapterData.starScores);
//分数置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 {
star3: eui.Image;
starProgress: eui.Image;
scoreTxt: eui.Label;
scoreTxt: CurScoreNum;
allScore: number;
private _score: number;
get score() {
......@@ -24,7 +25,7 @@ export class ScoreProgress {
set score(value: number) {
if (this._score == value) return
this._score = value
this.scoreTxt.text = Math.ceil(value) + "";
this.scoreTxt.num = Math.ceil(value);
var diss = [
188,
446,
......@@ -92,7 +93,7 @@ export class ScoreProgress {
* @param scoreTxt 托管
* @param starScores
*/
constructor(starProgress: eui.Image, scoreTxt: eui.Label, starScores: number[]) {
constructor(starProgress: eui.Image, scoreTxt: CurScoreNum, starScores: number[]) {
this.starProgress = starProgress;
this.scoreTxt = scoreTxt;
this.starScores = starScores;
......
......@@ -61,7 +61,7 @@ export class TargetNumber extends egret.DisplayObjectContainer {
center() {
//按顺序排,从右到左,
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;
for (var i = 0; i < this.$children.length; 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