Commit 9c455268 authored by Chen Jiping's avatar Chen Jiping

优化排版及音频播放问题

parent 631f7f50
...@@ -12,7 +12,7 @@ import { ...@@ -12,7 +12,7 @@ import {
} from './AudioUtil'; } from './AudioUtil';
import{ import {
Skin Skin
} from './Skin' } from './Skin'
...@@ -53,14 +53,14 @@ export class Exercises { ...@@ -53,14 +53,14 @@ export class Exercises {
this.index = exercisesData.index; this.index = exercisesData.index;
} }
init(skin : Skin, i){ init(skin: Skin, i) {
skin.initExercises(this, i); skin.initExercises(this, i);
} }
initBg2(width, height){ initBg2(width, height) {
//最底部背景 //最底部背景
const bg2 = new ShapeRect(); const bg2 = new ShapeRect();
...@@ -68,52 +68,52 @@ export class Exercises { ...@@ -68,52 +68,52 @@ export class Exercises {
bg2.addChild(this.bg); bg2.addChild(this.bg);
bg2.setSize(width, height); bg2.setSize(width, height);
if(this.bg instanceof ShapeRect){ if (this.bg instanceof ShapeRect) {
this.bg.x = 0; this.bg.x = (width - this.bg.width) / 2;
this.bg.y = 0; this.bg.y = 0;
} }
else{ else {
this.bg.x = width / 2; this.bg.x = width / 2;
this.bg.y = height - this.bg.getBoundingBox().height / 2; this.bg.y = height - this.bg.getBoundingBox().height / 2;
} }
this.bg2 = bg2; this.bg2 = bg2;
} }
checkRight(curIndex){ checkRight(curIndex) {
if(!curIndex){ if (!curIndex) {
return; return;
} }
if(curIndex == this.index){ if (curIndex == this.index) {
this.indexLabel.alpha = 1; this.indexLabel.alpha = 1;
this.indexShowed = true; this.indexShowed = true;
return true; return true;
} }
else{ else {
return false; return false;
} }
} }
playAudio(type, callback = null){ playAudio(type, callback = null) {
if(type == 'T'){ if (type == 'T') {
playAudio(this.audio, true); playAudio(this.audio, true);
return this.audio; return this.audio;
} }
else if(type == 'I'){ else if (type == 'I') {
playAudio(this.indexAudio); playAudio(this.indexAudio, true);
return this.indexAudio; return this.indexAudio;
} }
} }
getHeight(){ getHeight() {
return this.bg.getBoundingBox().height; return this.bg.getBoundingBox().height;
} }
getWidth(){ getWidth() {
return this.bg.getBoundingBox().width; return this.bg.getBoundingBox().width;
} }
} }
\ No newline at end of file
...@@ -28,6 +28,7 @@ export class Skin { ...@@ -28,6 +28,7 @@ export class Skin {
contentBgWidth = 0; contentBgWidth = 0;
minMarginTop = 0;
constructor(skinType, images) { constructor(skinType, images) {
...@@ -47,13 +48,17 @@ export class Skin { ...@@ -47,13 +48,17 @@ export class Skin {
this.intervalWidth = 28 * this.scaleX; this.intervalWidth = 28 * this.scaleX;
this.contentBgWidth = 348 * this.scaleX; this.contentBgWidth = 348 * this.scaleX;
this.minMarginTop = 160 * this.scaleY;
} }
else { else {
this.intervalHeight = 110 * this.scaleY; this.intervalHeight = 56 * this.scaleY;
this.intervalWidth = 63 * this.scaleX; this.intervalWidth = 63 * this.scaleX;
this.contentBgWidth = 320 * this.scaleX; this.contentBgWidth = 320 * this.scaleX;
this.minMarginTop = 77 * this.scaleY;
} }
} }
...@@ -272,4 +277,8 @@ export class Skin { ...@@ -272,4 +277,8 @@ export class Skin {
getContentBgWidth() { getContentBgWidth() {
return this.contentBgWidth; return this.contentBgWidth;
} }
getMinMarginTop(){
return this.minMarginTop;
}
} }
\ No newline at end of file
...@@ -655,7 +655,6 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -655,7 +655,6 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
for (let i = 0; i < this.exercisesArr.length; ++i) { for (let i = 0; i < this.exercisesArr.length; ++i) {
let j = Math.floor(i / col); let j = Math.floor(i / col);
...@@ -678,7 +677,9 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -678,7 +677,9 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
//起始y坐标 //起始y坐标
let startY = (this.canvasHeight - totalHeight) / 2 + this.title.titleBg.height; let startY = (this.canvasHeight - totalHeight) / 2;
startY = startY > this.skin.getMinMarginTop() ? startY : this.skin.getMinMarginTop();
let tempStartX = startX; let tempStartX = startX;
......
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