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

优化排版及音频播放问题

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