Commit d3ba6a76 authored by Chen Jiping's avatar Chen Jiping

改造完成

parent 8a51c964
...@@ -128,5 +128,8 @@ ...@@ -128,5 +128,8 @@
} }
} }
}, },
"defaultProject": "ng-template-generator" "defaultProject": "ng-template-generator",
} "cli": {
"analytics": "68306aac-25e4-415d-920b-a8cb1805d1f2"
}
}
\ No newline at end of file
This diff is collapsed.
...@@ -10,11 +10,10 @@ import {Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output, Ap ...@@ -10,11 +10,10 @@ import {Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output, Ap
export class FormComponent implements OnInit, OnChanges, OnDestroy { export class FormComponent implements OnInit, OnChanges, OnDestroy {
// 储存数据用 // 储存数据用
saveKey = "test_0011"; saveKey = "YM-42";
// 储存对象 // 储存对象
item; item;
constructor(private appRef: ApplicationRef,private changeDetectorRef: ChangeDetectorRef) { constructor(private appRef: ApplicationRef,private changeDetectorRef: ChangeDetectorRef) {
} }
...@@ -24,6 +23,12 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -24,6 +23,12 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
this.item = {}; this.item = {};
this.item.title = this.getDefaultTile();
this.item.exercisesArr = [];
console.log('item:', this.item);
// 获取存储的数据 // 获取存储的数据
(<any> window).courseware.getData((data) => { (<any> window).courseware.getData((data) => {
...@@ -31,6 +36,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -31,6 +36,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
this.item = data; this.item = data;
} }
console.log('item:', this.item);
this.init(); this.init();
this.changeDetectorRef.markForCheck(); this.changeDetectorRef.markForCheck();
this.changeDetectorRef.detectChanges(); this.changeDetectorRef.detectChanges();
...@@ -47,10 +53,29 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -47,10 +53,29 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
ngOnDestroy() { ngOnDestroy() {
} }
init() {
if(!this.item.title){
this.item.title = this.getDefaultTile();
}
init() { //设置默认皮肤
if(!this.item.skin){
this.item.skin = "A";
}
if(!this.item.exercisesArr || this.item.exercisesArr.length == 0){
this.item.exercisesArr = [];
for(let i = 0; i < 6; ++ i){
let exercises = this.getDefaultExercisesItem();
this.item.exercisesArr.push(exercises);
}
}
} }
...@@ -58,19 +83,19 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -58,19 +83,19 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
* 储存图片数据 * 储存图片数据
* @param e * @param e
*/ */
onImageUploadSuccess(e, key) { onImageUploadSuccess(e, item, key) {
this.item[key] = e.url; item[key] = e.url;
this.save(); this.save();
} }
/** /**
* 储存音频数据 * 储存音频数据
* @param e * @param e
*/ */
onAudioUploadSuccess(e, key) { onAudioUploadSuccess(e, item, key) {
this.item[key] = e.url; item[key] = e.url;
this.save(); this.save();
} }
...@@ -81,6 +106,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -81,6 +106,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
*/ */
save() { save() {
(<any> window).courseware.setData(this.item, null, this.saveKey); (<any> window).courseware.setData(this.item, null, this.saveKey);
this.changeDetectorRef.detectChanges();
this.refresh(); this.refresh();
} }
...@@ -93,5 +119,58 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -93,5 +119,58 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
}, 1); }, 1);
} }
/**
* 获取缺省的练习题内容
*/
getDefaultExercisesItem(){
const exercises = {
text:'',
pic_url:'',
audio_url:'',
letters:[]
};
return exercises;
}
getDefaultTile(){
const title = {
part1:'',
part2:'',
audio_url:''
};
return title;
}
/**
* 获取默认的字母
*/
getDefaultLetter(){
let letter = {
val:'',
isColor:'0'
};
return letter;
}
addLetter(exercises) {
let letter = this.getDefaultLetter();
exercises.letters = [...exercises.letters, letter];
this.save();
}
delLetter(exercises, index) {
if (index !== -1) {
exercises.letters.splice(index, 1);
exercises.letters = [...exercises.letters];
this.save();
}
}
} }
/**
*
* @param audio 音频
* @param now true-重新开始播放,flase-继续播放
* @param callback
*/
export function playAudio(audio, now = false, callback = null) {
if (audio) {
if (now) {
audio.pause();
audio.currentTime = 0;
}
if (callback) {
audio.onended = () => {
callback();
};
}
audio.play();
}
}
/**
* 暂停播放音频
* @param audio 音频
* @param reset 暂停是否重置:true-是,false-否
* @param callback
*/
export function pauseAudio(audio, reset = false, callback = null) {
if (audio) {
if (reset) {
audio.currentTime = 0;
}
audio.pause();
if (callback) {
callback();
}
}
}
\ No newline at end of file
This diff is collapsed.
import {
Label,
MySprite, ShapeRectNew,
ShapeCircle,
tweenChange,
ShapeRect
} from './Unit';
import {
playAudio,
pauseAudio
} from './AudioUtil';
export class Listening {
audio;
images;
bg;
btnPlay;
btnStop;
playing = false;
constructor(audio, images) {
this.audio = audio;
this.images = images;
}
init(scaleX = 1, scaleY = 1) {
const bg = new ShapeRect();
const btnPlay = new MySprite();
btnPlay.init(this.images.get('play'));
btnPlay.scaleX = scaleX;
btnPlay.scaleY = scaleY;
btnPlay.x = btnPlay.getBoundingBox().width / 2
btnPlay.y = btnPlay.getBoundingBox().height / 2
this.btnPlay = btnPlay;
bg.addChild(btnPlay);
const btnStop = new MySprite();
btnStop.init(this.images.get('stop'));
btnStop.x = btnPlay.x;
btnStop.y = btnPlay.y;
btnStop.alpha = 0;
btnStop.scaleX = scaleX;
btnStop.scaleY = scaleY;
this.btnStop = btnStop;
bg.addChild(btnStop);
bg.setSize(btnPlay.getBoundingBox().width, btnPlay.getBoundingBox().height);
bg.alpha = 0;
this.bg = bg;
}
play(callback = null){
console.log('playing:', this.playing);
if(!this.playing){
this.playAudio(callback);
return this.audio;
}
else{
this.pauseAudio(callback);
}
return null;
}
playAudio(callback = null){
this.btnPlay.alpha = 0;
this.btnStop.alpha = 1;
playAudio(this.audio, false, callback);
this.playing = true;
return this.audio;
}
pauseAudio(callback){
this.btnPlay.alpha = 1;
this.btnStop.alpha = 0;
this.playing = false;
pauseAudio(this.audio, false, callback)
}
}
\ No newline at end of file
import {
Label,
MySprite, ShapeRect,
} from './Unit';
import {
playAudio,
pauseAudio
} from './AudioUtil';
export class Title {
titleBg: ShapeRect;
audio;
images;
titleData;
constructor(titleData, images) {
this.titleData = titleData;
this.images = images;
}
init(mapScaleX = 1, mapScaleY = 1) {
//初始化标题1背景
const titePart1Bg = new MySprite();
titePart1Bg.init(this.images.get('titlePart1Bg'));
titePart1Bg.scaleX = mapScaleX;
titePart1Bg.scaleY = mapScaleY;
titePart1Bg.x = titePart1Bg.getBoundingBox().width / 2;
//标题1内容
const part1 = new Label();
part1.text = this.titleData.part1;
part1.textAlign = 'left';
part1.fontSize = 48;
part1.fontName = "BRLNSDB";
part1.fontColor = "#000000";
part1.refreshSize();
part1.x = titePart1Bg.getBoundingBox().width / 2 - part1.getBoundingBox().width - 13 * mapScaleX;
titePart1Bg.addChild(part1);
//标题2内容
const part2 = new Label();
part2.text = this.titleData.part2;
part2.fontSize = 36;
part2.fontName = "FuturaStd";
part2.fontColor = "#000000";
part2.refreshSize();
part2.x = titePart1Bg.getBoundingBox().width + 11 * mapScaleX;
part2.y = 10 * mapScaleY + part2.getBoundingBox().height / 2;
let height = Math.max(titePart1Bg.getBoundingBox().height, part2.getBoundingBox().height);
let width = titePart1Bg.getBoundingBox().width + part2.getBoundingBox().width + 11 * mapScaleX;
let titleBg = new ShapeRect();
titleBg.setSize(width, height);
titleBg.alpha = 0;
titePart1Bg.y = height / 2;
titleBg.addChild(titePart1Bg);
part2.y = height / 2;
titleBg.addChild(part2);
this.titleBg = titleBg;
}
getTitleBg(){
return this.titleBg;
}
setAudio(audio){
this.audio = audio;
}
playAudio(callback = null){
playAudio(this.audio, true, callback);
return this.audio;
}
pasueAudio(callback){
pauseAudio(this.audio, true, callback)
}
}
export function getDefaultTile() {
let title = {
part1: 'A',
part2: 'Read and point',
audio_url: ''
};
return title;
}
\ No newline at end of file
...@@ -1169,6 +1169,48 @@ export class MyAnimation extends MySprite { ...@@ -1169,6 +1169,48 @@ export class MyAnimation extends MySprite {
} }
export class Line extends MySprite{
lineColor = '#ffffff';
lineWidth = 10;
_sX = 0;
_sY = 0;
_tX = 0;
_tY = 0;
setLine(sX, sY, tX, tY){
this._sX = sX;
this._sY = sY;
this._tX = tX;
this._tY = tY;
}
drawLine() {
this.ctx.beginPath();
this.ctx.moveTo(this._sX, this._sY);
this.ctx.lineTo(this._tX, this._tY);
this.ctx.lineWidth = this.lineWidth;
this.ctx.strokeStyle = this.lineColor;
this.ctx.stroke();
}
drawSelf() {
super.drawSelf();
this.drawLine();
}
}
......
...@@ -17,3 +17,38 @@ ...@@ -17,3 +17,38 @@
src: url("../../assets/font/BRLNSDB.TTF") ; src: url("../../assets/font/BRLNSDB.TTF") ;
} }
@font-face
{
font-family: 'FUTURAB';
src: url("../../assets/font/FUTURAB.TTF") ;
}
@font-face
{
font-family: 'GOTHIC';
src: url("../../assets/font/GOTHIC.TTF") ;
}
@font-face
{
font-family: 'GOTHICB';
src: url("../../assets/font/GOTHICB.TTF") ;
}
@font-face
{
font-family: 'TCB';
src: url("../../assets/font/TCB.TTF") ;
}
@font-face
{
font-family: 'FUTURA';
src: url("../../assets/font/Futura.ttc") ;
}
@font-face
{
font-family: 'FuturaStd';
src: url("../../assets/font/FuturaStd-Medium.otf") ;
}
\ No newline at end of file
This diff is collapsed.
const res = [ const res = [
// ['bg', "assets/play/bg.jpg"], ['play', "assets/play/play.png"],
['btn_left', "assets/play/btn_left.png"], ['stop', "assets/play/stop.png"],
['btn_right', "assets/play/btn_right.png"], ['titlePart1Bg', "assets/play/title-part1-bg.png"],
// ['text_bg', "assets/play/text_bg.png"], ['close', "assets/play/close.png"],
['overturn', "assets/play/overturn.png"],
['box', "assets/play/box.png"],
]; ];
...@@ -12,7 +13,9 @@ const res = [ ...@@ -12,7 +13,9 @@ const res = [
const resAudio = [ const resAudio = [
['click', "assets/play/music/click.mp3"], ['click', "assets/play/music/click.mp3"],
['back', "assets/play/music/back.mp3"],
['waves', "assets/play/music/waves.mp3"],
['turn', "assets/play/music/turn.mp3"],
]; ];
export {res, resAudio}; export {res, resAudio};
This diff is collapsed.
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