Commit 9535f9f5 authored by 邱旭's avatar 邱旭

1

parent a8b84604
......@@ -6,9 +6,9 @@
<e:Image x="0" y="0" source="playSceneBg_jpg"/>
<e:Image y="247" source="targetBoard_png" x="174"/>
<e:Image y="0" source="progressDown_png" horizontalCenter="0"/>
<e:Image id="starProgress" x="131" y="201.85" source="starProgress_png"/>
<e:Image id="starProgress" x="138" y="206.85" source="starProgress_png"/>
<e:Image x="69" y="-1.15" source="stepsBoard_png"/>
<e:Image x="226.5" y="214.85" source="dangqianfenshu_png"/>
<e:Image x="171.5" y="213.85" source="dangqianfenshu_png"/>
......@@ -46,7 +46,6 @@
<e:Image id="progressmask2" y="9.14" x="16" source="mask2_png" width="444" height="60" scaleX="1" visible="false"/>
</e:Group>
</e:Group>
<e:BitmapLabel width="20" height="20" x="531" y="132"/>
......
......@@ -436,20 +436,20 @@ export default class MainScene extends Scene {
//第几关
var chapterTxt = new ChapterNum();
chapterTxt.num = `第${this.chapter}关` // >> 0;
chapterTxt.x = 500;
chapterTxt.x = 520;
chapterTxt.y = 148
this.addChild(chapterTxt)
//步数
this.stepNumber = new StepNumber();
this.stepNumber.x = 123;
this.stepNumber.y = 91;
this.stepNumber.x = 175;
this.stepNumber.y = 131;
this.addChild(this.stepNumber);
//步数初始化
this.steps = this.chapterData.stepCount;
//当前分数
var curScoreNum = new CurScoreNum();
curScoreNum.x = 322;
curScoreNum.y = 92;
curScoreNum.x = 284;
curScoreNum.y = 217.5;
this.addChild(curScoreNum);
//分数进度条,托管
......
......@@ -4,7 +4,7 @@ import { CurScoreNum } from "./CurScoreNum";
* 分数条的托管类,不需要继承
*/
export class ScoreProgress {
hasOver: boolean
hasOver: boolean;
starCount: number = 0;
/**
* 各星数的对应分数
......@@ -22,69 +22,66 @@ export class ScoreProgress {
get score() {
return this._score
}
set score(value: number) {
if (this._score == value) return
this._score = value
if(this._score == value) return;
this._score = value;
this.scoreTxt.num = Math.ceil(value);
var diss = [
188,
446,
522,
595,
663
]
var w: number, scale: number;
//先计算是否达到了3星
if (value >= this.starScores[2]) {
if(value >= this.starScores[2]) {
var aa = (value - this.starScores[2]) / (this.allScore - this.starScores[2]);
scale = aa > 1 ? 1 : aa;
if (scale >= 1) {
if (!this.hasOver) {
if(scale >= 1) {
if(!this.hasOver) {
this.hasOver = true;
} else {
return
}
}
w = (663 - 595) * scale + 595;
if (this.star3.source != "lightedStar_png") {
w = (640 - 563) * scale + 563 - 138;
if(this.star3.source != "lightedStar_png") {
this.star3.source = "lightedStar_png";
this.star2.source = "lightedStar_png";
this.star1.source = "lightedStar_png";
this.starCount = 3;
};
}
}
//是否超过2星
else if (value >= this.starScores[1]) {
else if(value >= this.starScores[1]) {
scale = (value - this.starScores[1]) / (this.starScores[2] - this.starScores[1]);
w = (595 - 522) * scale + 522;
if (this.star2.source != "lightedStar_png") {
w = (536 - 476) * scale + 476 - 138;
if(this.star2.source != "lightedStar_png") {
this.star2.source = "lightedStar_png";
this.star1.source = "lightedStar_png";
this.starCount = 2;
};
}
}
//是否超过1星
else if (value >= this.starScores[0]) {
else if(value >= this.starScores[0]) {
scale = (value - this.starScores[0]) / (this.starScores[1] - this.starScores[0]);
w = (522 - 446) * scale + 446;
if (this.star1.source != "lightedStar_png") {
w = (476 - 390) * scale + 390 - 138;
if(this.star1.source != "lightedStar_png") {
this.star1.source = "lightedStar_png";
this.starCount = 1;
};
}
} else {
scale = value / this.starScores[0];
w = (446 - 188) * scale + 188;
w = (390 - 138) * scale;
}
//(466-428)/428,扩分数
//星星
//进度条遮罩
var mask: any = this.starProgress.mask;
mask.graphics.clear()
// let mask = window['aaa'];
mask.graphics.clear();
mask.graphics.beginFill(0xff0000, 1);
mask.graphics.drawRoundRect(0, 75, w, 48, 50)
mask.graphics.drawRoundRect(138, 203, w, 48, 50);
mask.graphics.endFill();
}
/**
......@@ -97,28 +94,32 @@ export class ScoreProgress {
this.starProgress = starProgress;
this.scoreTxt = scoreTxt;
this.starScores = starScores;
this.allScore = 466 / 428 * this.starScores[2];
this.allScore = 640 / 563 * this.starScores[2];
//加遮罩,加到starProgress的父级中
var p = starProgress.parent;
var mask = new egret.Shape();
// window['aaa'] = mask;
mask.graphics.beginFill(0xff0000, 1);
mask.graphics.drawRoundRect(0, 75, 188, 48, 50)
mask.graphics.drawRoundRect(138, 203, 0, 41, 50);
mask.graphics.endFill();
this.starProgress.mask = mask;
p.addChild(mask);
//星星1 lightedStar_png
var textureStar = RES.getRes("unlightedStar_png")
this.star1 = new eui.Image(textureStar)
this.star1.x = 423;
this.star1.y = 78;
var textureStar = RES.getRes("unlightedStar_png");
this.star1 = new eui.Image(textureStar); // width (27 * 2)
this.star1.x = 363;
this.star1.y = 201;
p.addChild(this.star1);
this.star2 = new eui.Image(textureStar);
this.star2.x = 498;
this.star2.y = 78;
this.star2.x = 449;
this.star2.y = 201;
p.addChild(this.star2);
this.star3 = new eui.Image(textureStar);
this.star3.x = 573;
this.star3.y = 76;
this.star3.x = 536;
this.star3.y = 201;
p.addChild(this.star3);
}
}
\ No newline at end of file
......@@ -13,13 +13,14 @@ export class StepNumber extends egret.DisplayObjectContainer {
get num(): number {
return this._num
}
set num(value: number) {
if (value == this._num) return;
if(value == this._num) return;
this._num = value;
var arr = Tool.returnTO(value);
if (arr.length > 2) arr = [9, 9];
if(arr.length > 2) arr = [9, 9];
this.ones.num = arr[0];
if (arr[1]) {
if(arr[1]) {
this.tens.visible = true;
this.tens.num = arr[1];
} else {
......@@ -28,6 +29,7 @@ export class StepNumber extends egret.DisplayObjectContainer {
//居中适配
this.center()
}
/**
* 个位
*/
......@@ -36,12 +38,13 @@ export class StepNumber extends egret.DisplayObjectContainer {
* 十位
*/
private tens: BitmapNumber;
constructor() {
super();
this.ones = new BitmapNumber("stepNumber");
this.tens = new BitmapNumber("stepNumber");
this.addChild(this.ones)
this.addChild(this.tens)
this.addChild(this.ones);
this.addChild(this.tens);
this.num = 0;
}
......@@ -49,9 +52,9 @@ export class StepNumber extends egret.DisplayObjectContainer {
* 居中位置
*/
center() {
if (this.tens.visible) {
if(this.tens.visible) {
this.ones.x = 0;
this.tens.x = - this.tens.texture.textureWidth;
this.tens.x = -this.tens.texture.textureWidth;
} else {
this.ones.x = -this.ones.texture.textureWidth / 2
}
......
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