Commit 8c4ec4f8 authored by limingzhe's avatar limingzhe

update

parent 4b326c83
...@@ -18,66 +18,66 @@ ...@@ -18,66 +18,66 @@
font-family: 'BRLNSDB'; font-family: 'BRLNSDB';
src: url("../../../assets/font/BRLNSDB.TTF") ; src: url("../../../assets/font/BRLNSDB.TTF") ;
} }
//
@font-face //@font-face
{ //{
font-family: 'BRLNSB'; // font-family: 'BRLNSB';
src: url("../../../assets/font/BRLNSB.TTF") ; // src: url("../../../assets/font/BRLNSB.TTF") ;
} //}
//
@font-face //@font-face
{ //{
font-family: 'BRLNSR'; // font-family: 'BRLNSR';
src: url("../../../assets/font/BRLNSR.TTF") ; // src: url("../../../assets/font/BRLNSR.TTF") ;
} //}
//
@font-face //@font-face
{ //{
font-family: 'GOTHIC'; // font-family: 'GOTHIC';
src: url("../../../assets/font/GOTHIC.TTF") ; // src: url("../../../assets/font/GOTHIC.TTF") ;
} //}
//
@font-face //@font-face
{ //{
font-family: 'GOTHICB'; // font-family: 'GOTHICB';
src: url("../../../assets/font/GOTHICB.TTF") ; // src: url("../../../assets/font/GOTHICB.TTF") ;
} //}
//
@font-face //@font-face
{ //{
font-family: 'GOTHICBI'; // font-family: 'GOTHICBI';
src: url("../../../assets/font/GOTHICBI.TTF") ; // src: url("../../../assets/font/GOTHICBI.TTF") ;
} //}
//
@font-face //@font-face
{ //{
font-family: 'GOTHICI'; // font-family: 'GOTHICI';
src: url("../../../assets/font/GOTHICI.TTF") ; // src: url("../../../assets/font/GOTHICI.TTF") ;
} //}
//
@font-face //@font-face
{ //{
font-family: 'MMTextBook'; // font-family: 'MMTextBook';
src: url("../../../assets/font/MMTextBook.otf") ; // src: url("../../../assets/font/MMTextBook.otf") ;
} //}
//
@font-face //@font-face
{ //{
font-family: 'MMTextBook-Bold'; // font-family: 'MMTextBook-Bold';
src: url("../../../assets/font/MMTextBook-Bold.otf") ; // src: url("../../../assets/font/MMTextBook-Bold.otf") ;
} //}
//
@font-face //@font-face
{ //{
font-family: 'MMTextBook-BoldItalic'; // font-family: 'MMTextBook-BoldItalic';
src: url("../../../assets/font/MMTextBook-BoldItalic.otf") ; // src: url("../../../assets/font/MMTextBook-BoldItalic.otf") ;
} //}
//
@font-face //@font-face
{ //{
font-family: 'MMTextBook-Italic'; // font-family: 'MMTextBook-Italic';
src: url("../../../assets/font/MMTextBook-Italic.otf") ; // src: url("../../../assets/font/MMTextBook-Italic.otf") ;
} //}
@mixin tool-btn { @mixin tool-btn {
border: 1px solid #ddd; border: 1px solid #ddd;
display: flex; display: flex;
......
@import '../style/common_mixin.css';
.model-content {
width: 100%;
height: 100%;
}
This diff is collapsed.
@import "../style/common_mixin";
.model-content {
.card-config {
width: 100%;
height: 100%;
margin-left: 10px;
display: flex;
flex-wrap: wrap;
.card-item{
flex:1;
.border {
border-radius: 20px;
border-style: dashed;
padding:20px;
width: 800px;
}
.card-item-content{
.title {
font-size: 24px;
width: 100%;
text-align: center;
}
.section{
border-top: 1px solid ;
padding: 10px 0;
.section-title{
font-size: 24px;
width: 100%;
}
.section-content{
display: flex;
margin: 5px 0 10px 0;
}
}
.pic-sound-box {
width: 50%;
display: flex;
flex-direction: column;
}
.add-btn-box {
display: flex;
align-items: center;
justify-content: center;
height: 20vw;
padding: 10px;
padding-top: 5vw;
}
}
}
}
}
import {Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output, ApplicationRef} from '@angular/core'; import {Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output, ApplicationRef} from '@angular/core';
@Component({ @Component({
selector: 'app-form', selector: 'app-form',
templateUrl: './form.component.html', templateUrl: './form.component.html',
styleUrls: ['./form.component.css'] styleUrls: ['./form.component.scss']
}) })
export class FormComponent implements OnInit, OnChanges, OnDestroy { export class FormComponent implements OnInit, OnChanges, OnDestroy {
// 储存数据用 dataArray = [];
saveKey = "test_0011"; _item: any;
// 储存对象 KEY = 'DataKey_MultipleChoice';
item;
set item(item) {
this._item = item;
}
get item() {
return this._item;
}
@Output()
update = new EventEmitter();
constructor(private appRef: ApplicationRef) { constructor(private appRef: ApplicationRef) {
} }
ngOnInit() { ngOnInit() {
this.item = {}; this.item = {};
this.item.contentObj = {};
// 获取存储的数据 const getData = (<any> window).courseware.getData;
(<any> window).courseware.getData((data) => { getData((data) => {
if (data) { if (data) {
this.item = data; this.item = data;
} else {
this.item = {};
}
if ( !this.item.contentObj ) {
this.item.contentObj = {};
} }
this.init(); this.init();
this.refresh(); this.refresh();
this.saveItem();
}, this.saveKey); }, this.KEY);
} }
ngOnChanges() { ngOnChanges() {
} }
ngOnDestroy() { ngOnDestroy() {
} }
init() { init() {
if (this.item.contentObj.dataArray) {
this.dataArray = this.item.contentObj.dataArray;
} else {
this.dataArray = this.getDefaultPicArr();
this.item.contentObj.dataArray = this.dataArray;
}
}
cardItemData(){
return {
time: 3,
question:{
text:"",
image_url:"",
audio_url:""
},
choice:{
correct:{ isText: true, text: "", image_url: "" },
incorrect:[
{ isText: true, text: "", image_url: "" },
{ isText: true, text: "", image_url: "" },
{ isText: true, text: "", image_url: "" },
]
}
};
} }
cardChoiceData(){
return { isText: true, text: "", image_url: "" }
}
getDefaultPicArr() {
let arr = [];
return arr;
}
/**
* 储存图片数据
* @param e
*/
onImageUploadSuccess(e, key) {
this.item[key] = e.url; initData() {
this.save();
} }
/** deleteItem(index) {
* 储存音频数据 if (index !== -1) {
* @param e this.dataArray.splice(index, 1);
*/ }
onAudioUploadSuccess(e, key) { this.save();
}
deleteChoice(questionIndex, choiceIndex){
if (questionIndex !== -1 && choiceIndex !== -1) {
this.dataArray[questionIndex].choice.incorrect.splice(choiceIndex, 1);
}
this.save();
}
addChoice(questionIndex) {
let item = this.cardChoiceData();
this.dataArray[questionIndex].choice.incorrect.push(item);
this.saveItem();
}
this.item[key] = e.url; onImageUploadSuccessByItem(e, item) {
item.image_url = e.url
this.save();
}
onAudioUploadSuccessByItem(e, item) {
item.audio_url = e.url;
this.save();
}
onTitleAudioUploadSuccess(e) {
this.item.contentObj.titleAudio_url = e.url;
this.save(); this.save();
} }
addItem() {
let item = this.cardItemData();
this.dataArray.push(item);
this.saveItem();
}
radioClick(it, radioValue) {
it.radioValue = radioValue;
this.saveItem();
}
clickCheckBox() {
this.saveItem();
}
saveItem() {
this.save();
}
/**
* 储存数据
*/
save() { save() {
(<any> window).courseware.setData(this.item, null, this.saveKey); (<any> window).courseware.setData(this.item, null, this.KEY);
this.refresh(); this.refresh();
console.log(this.item)
} }
/**
* 刷新 渲染页面
*/
refresh() { refresh() {
setTimeout(() => { setTimeout(() => {
this.appRef.tick(); this.appRef.tick();
......
import {
MySprite,
getMinScale,
ShapeRect,
tweenChange,
randomSortByArr,
Label,
showPopParticle,
moveItem,
removeItemFromArr,
rotateItem,
ShapeRectNew
} from "./Unit";
import { CartoonAnimation } from './CartoonAnimation'
export class Cartoon {
// 系统缩放比例
mapScale = 1;
stageWidth;
stageHeight;
clientWidth;
clientHeight;
// 音乐 和 图片的缓冲区
audio = new Map();
images = new Map();
imagesOriginSize = new Map();
// 坐标原点 包含缩放
originX = 0;
originY = 0;
setOrigin = (x, y)=>{
this.originX = x;
this.originY = y;
}
getOrigin = ()=>{
return {
x: this.originX,
y: this.originY
}
}
// 相对坐标原点 包含缩放 用于添加孩子动画元素
relativeOriginX = 0;
relativeOriginY = 0;
setRelativeOrigin = (x, y)=>{
this.relativeOriginX = x;
this.relativeOriginY = y;
}
getRelativeOrigin = ()=>{
return {
x: this.relativeOriginX,
y: this.relativeOriginY
}
}
// 存放音乐和图片的地址
audioObj = {}
imageObj = {}
_currentPlayAudio;
// 添加音乐
addAudio = ( key, url ) => {
this.audioObj[key] = url
};
// 添加音乐
addImage = ( key, url ) => {
this.imageObj[key] = url
};
// 播放音乐
_playingNow = []
playAudio = function( key, now = false, callback = null) {
const audio = this.audio.get(key);
if (audio) {
if (now) {
audio.pause();
audio.currentTime = 0;
}
if (callback) {
audio.onended = () => {
let index = this._playingNow.indexOf(audio)
if(index != -1){
this._playingNow.splice(index,1)
}
callback();
};
}
audio.play();
audio.callback = callback
this._playingNow.push(audio)
this._currentPlayAudio = audio;
}
}
stopAllAudio(){
this._playingNow.forEach(audio=>{
audio.onended && audio.onended()
audio.pause();
audio.currentTime = 0;
})
this._playingNow = []
}
stopAudio(){
if(this._currentPlayAudio){
this._currentPlayAudio.pause();
this._currentPlayAudio.currentTime = 0;
}
}
// 异步加载图片 音频资源
loadResources = ()=> {
const pr = [];
for(let key in this.imageObj){
const p = this.preloadImage(this.imageObj[key]).then( (img:any) => {
this.images.set(key, img);
this.imagesOriginSize.set(key, {width:img.width, height:img.height});
}).catch(err => console.log(key));
pr.push(p);
};
for(let key in this.audioObj){
const a = this.preloadAudio(this.audioObj[key]).then( (audio:any) => {
this.audio.set(key, audio);
}).catch(err => console.log(key));
pr.push(a);
};
return Promise.all(pr);
}
// 预加载图片
preloadImage = (url) => {
return new Promise((resolve, reject) => {
const img = new Image();
img.src = url;
img.onload = () => resolve(img);
img.onerror = reject;
img.src = url;
});
}
// 预加载音频
preloadAudio = (url) => {
return new Promise((resolve, reject) => {
const audio = new Audio();
audio.oncanplay = a => {
resolve(audio);
};
audio.onerror = () => {
reject();
};
audio.src = url;
audio.load();
});
}
// 缓存页面元素
cartoonElementsBuffer = {}
createCartoonElement = (key, type, width?:number, heigth?:number, initX?:number, initY?:number)=>{
this.cartoonElementsBuffer[key] = {}
this.cartoonElementsBuffer[key].id = key;
this.cartoonElementsBuffer[key].width = width;
this.cartoonElementsBuffer[key].heigth = heigth;
this.cartoonElementsBuffer[key].width = width;
this.cartoonElementsBuffer[key].heigth = heigth;
this.cartoonElementsBuffer[key].x = initX;
this.cartoonElementsBuffer[key].y = initY;
switch(type){
case "MySprite": this.cartoonElementsBuffer[key].ref = new MySprite(); break;
case "ShapeRect": this.cartoonElementsBuffer[key].ref = new ShapeRect(); break;
case "ShapeRectNew": this.cartoonElementsBuffer[key].ref = new ShapeRectNew(); break;
case "Label": this.cartoonElementsBuffer[key].ref = new Label(); break;
default : this.cartoonElementsBuffer[key].ref = new MySprite(); break;
}
this.cartoonElementsBuffer[key].ref.x = initX;
this.cartoonElementsBuffer[key].ref.y = initY;
this.cartoonElementsBuffer[key].animation = new CartoonAnimation(this.cartoonElementsBuffer[key].ref)
return this.cartoonElementsBuffer[key]
}
createElement = (type, initX?:number, initY?:number)=>{
let element;
switch(type){
case "MySprite": element = new MySprite(); break;
case "ShapeRect": element = new ShapeRect(); break;
default : element = new MySprite(); break;
}
element.x = initX;
element.y = initY;
return element
}
createLabel = ({
text,
fontName,
fontColor,
fontSize,
textAlign
}, initX?, initY?)=>{
let element = new Label()
element.text = text;
element.fontName = fontName;
element.fontColor = fontColor;
element.fontSize = fontSize;
element.textAlign = textAlign;
element.x = initX;
element.y = initY;
return element
}
getCartoonElementRef = (key)=>{
if(this.cartoonElementsBuffer[key]){
return this.cartoonElementsBuffer[key].ref;
}else{
return undefined
}
}
getCartoonElement = (key)=>{
return this.cartoonElementsBuffer[key]
}
setCartoonElementPosition = (key, posi)=>{
this.cartoonElementsBuffer[key].ref.x = posi.x
this.cartoonElementsBuffer[key].ref.y = posi.y
this.cartoonElementsBuffer[key].x = posi.x
this.cartoonElementsBuffer[key].y = posi.y
}
setCartoonElementPositionX = (key, x)=>{
this.cartoonElementsBuffer[key].ref.x = x
this.cartoonElementsBuffer[key].x = x
}
setCartoonElementRelativePositionX = (key, x)=>{
this.cartoonElementsBuffer[key].relativeX = x
}
setCartoonElementPositionY = (key, y)=>{
this.cartoonElementsBuffer[key].ref.y = y
this.cartoonElementsBuffer[key].y = y
}
setCartoonElementRelativePositionY = (key, y)=>{
this.cartoonElementsBuffer[key].relativeY = y
}
getCartoonElementPosition = (key)=>{
return {
x: this.cartoonElementsBuffer[key].x,
y: this.cartoonElementsBuffer[key].y
}
}
getCartoonElementRelativePosition = (key)=>{
return {
x: this.cartoonElementsBuffer[key].relativeX,
y: this.cartoonElementsBuffer[key].relativeY
}
}
animation = new CartoonAnimation(this)
}
\ No newline at end of file
import {
MySprite,
getMinScale,
ShapeRect,
tweenChange,
randomSortByArr,
Label,
showPopParticle,
moveItem,
removeItemFromArr,
rotateItem
} from "./Unit";
export class CartoonAnimation {
animations = {}
currentRef;
constructor(ref){
this.currentRef = ref
}
add(key:string, func:Function){
this.animations[key] = func
}
move = (ele, distPosition, runTime, callback?:Function )=>{
tweenChange(ele, distPosition, runTime, ()=>{
callback && callback()
});
}
scaleChange = this.move;
run( key:string ){
this.animations[key]()
}
overCard = function (callback?: any){
let w = this.currentRef.scaleX;
this.scaleChange(this.currentRef, { scaleX: 0 }, 0.3, () => {
this.currentRef.frontSide.visible = !this.currentRef.frontSide.visible;
this.currentRef.backSide.visible = !this.currentRef.backSide.visible;
this.scaleChange(this.currentRef, { scaleX: w }, 0.3, () => {
callback && callback();
});
});
}
}
\ No newline at end of file
This diff is collapsed.
.game-container {
width: 100%;
height: 100%;
background: #ffffff;
background-size: cover;
}
#canvas {
}
@font-face
{
font-family: 'BRLNSDB';
src: url("../../assets/font/BRLNSDB.TTF") ;
}
.game-container {
width: 100%;
height: 100%;
//background-image: url("/assets/listen-read-circle/bg.jpg");
background: #ffffff;
background-repeat: no-repeat;
background-size: cover;
}
.read-and-point-copy {
width: 500px;
height: 85px;
object-fit: contain;
text-shadow: 0 6px 4px rgba(0, 0, 0, 0.5), 0 3px 0 #fffecc;
font-family: Questrian;
font-size: 72px;
font-weight: normal;
font-stretch: normal;
font-style: normal;
line-height: normal;
letter-spacing: normal;
color: #f8e424;
}
.read-and-point-copy .text-style-1 {
font-size: 48px;
}
.read-and-point-copy .text-style-2 {
font-size: 64px;
}
@font-face
{
font-family: 'BRLNSDB';
src: url("../../assets/font/BRLNSDB.TTF") ;
}
@font-face
{
font-family: 'RoundedBold';
src: url("../../assets/font/ArialRoundedBold.otf") ;
}
@font-face{
font-family: 'BRLNSB_1';
src: url("../../assets/font/BerlinSansFB/BRLNSB_1.TTF") ;
}
@font-face{
font-family: 'BerlinSansFBDemi-Bold';
src: url("../../assets/font/BerlinSansFB/BRLNSDB_1.TTF") ;
}
@font-face{
font-family: 'BRLNSR_1';
src: url("../../assets/font/BerlinSansFB/BRLNSR_1.TTF") ;
}
@font-face{
font-family: 'GOTHIC_1';
src: url("../../assets/font/CenturyGothic/GOTHIC_1.TTF") ;
}
@font-face{
font-family: 'GOTHICB_1';
src: url("../../assets/font/CenturyGothic/GOTHICB_1.TTF") ;
}
@font-face{
font-family: 'GOTHICBI_1';
src: url("../../assets/font/CenturyGothic/GOTHICBI_1.TTF") ;
}
@font-face{
font-family: 'GOTHICI_1';
src: url("../../assets/font/CenturyGothic/GOTHICI_1.TTF") ;
}
@font-face{
font-family: 'MMTextBook';
src: url("../../assets/font/MMTextBook/MMTextBook.otf") ;
}
@font-face{
font-family: 'MMTextBook-Bold';
src: url("../../assets/font/MMTextBook/MMTextBook-Bold.otf") ;
}
@font-face{
font-family: 'MMTextBook-BoldItalic';
src: url("../../assets/font/MMTextBook/MMTextBook-BoldItalic.otf") ;
}
@font-face{
font-family: 'MMTextBook-Italic';
src: url("../../assets/font/MMTextBook/MMTextBook-Italic.otf") ;
}
This diff is collapsed.
const res = [ const localImages = {
'startBtn': "assets/play/btn-start.png",
'restartBtn': "assets/play/btn-restart.png",
'petal_1': "assets/play/scrap-pic-1.png",
'petal_2': "assets/play/scrap-pic-2.png",
'petal_3': "assets/play/scrap-pic-3.png",
'bg_1280_720_Ruler': "assets/play/1280_720_Ruler.png",
'bubble': "assets/play/bubble.png",
'replay': 'assets/play/replay.png',
'title': 'assets/play/multiple-choice.png',
'group': 'assets/play/group.png',
'rectangle-3': 'assets/play/rectangle-3.png',
'drop-down': 'assets/play/drop-down.png',
'combined-shape': 'assets/play/combined-shape.png',
'choice-card-typeA': 'assets/play/choice-card-a.png',
'choice-card-typeB': 'assets/play/choice-card-b.png',
'choice-card-typeC': 'assets/play/choice-card-c.png',
'choice-card-typeD': 'assets/play/choice-card-d.png',
'complete-card': 'assets/play/complete-card.png',
'header': 'assets/play/header.png',
'background': 'assets/play/background.png',
'question-image': 'assets/play/question-image.png',
'speaker-1': 'assets/play/speaker-1.png',
'correct-icon': 'assets/play/correct-icon.png',
'incorrect-icon': 'assets/play/incorrect-icon.png',
'red-circle': 'assets/play/combined-shape-red-circle.png',
'rectangle-4': 'assets/play/rectangle-4.png',
'me': 'assets/play/me.png',
'bg-240-180': 'assets/play/bg-240-180.png',
'bg-453-251': 'assets/play/bg-453-251.png',
't_right': "assets/play/right.png",
't_arrow': "assets/play/arrow.png",
'bg_500_600': "assets/play/bg_500_600.png",
'bg_1280_222': "assets/play/bg_1280_222.png",
'bg_ready': "assets/play/bg_ready.png",
'ready': "assets/play/ready.png",
'go': "assets/play/go.png"
};
// ['bg', "assets/play/bg.jpg"],
['btn_left', "assets/play/btn_left.png"],
['btn_right', "assets/play/btn_right.png"],
// ['text_bg', "assets/play/text_bg.png"],
]; const localAudios = {
'sm-back': "assets/audio/sm-back.mp3",
'sm-display': "assets/audio/sm-display.mp3",
'sm-wrong': "assets/audio/sm-wrong.mp3",
'sm-win': "assets/audio/sm-win.mp3",
'sm-in': "assets/audio/sm-in.mp3",
'sm-out': "assets/audio/sm-out.mp3",
'sm-click': "assets/audio/sm-click.mp3",
'sm-start': "assets/audio/sm-start.mp3",
'sm-correct': 'assets/audio/sm-correct.mp3',
'sm-choice-complete': 'assets/audio/sm-choice-complete.mp3',
'sm-choice-correct': 'assets/audio/sm-choice-correct.mp3',
'sm-choice-incorrect': 'assets/audio/sm-choice-error.mp3',
'sm-choice-in': 'assets/audio/sm-choice-in.mp3',
'sm-choice-show-answer': 'assets/audio/sm-choice-show-answer.mp3',
'sm-choice-timeup-0': 'assets/audio/sm-choice-timeup-0.mp3',
'sm-choice-timeup-3': 'assets/audio/sm-choice-timeup-3.mp3',
'sm-go': 'assets/audio/sm-go.mp3',
'sm-ready': 'assets/audio/sm-ready.mp3'
};
export {localImages, localAudios};
const resAudio = [
['click', "assets/play/music/click.mp3"],
];
export {res, resAudio};
import {
MySprite,
getMinScale,
ShapeRect,
tweenChange,
randomSortByArr,
Label,
showPopParticle,
moveItem,
removeItemFromArr,
rotateItem
} from "./Unit";
const myUtility = {};
// 系统缩放比例
myUtility.mapScale = 1;
// 音乐 和 图片的缓冲区
myUtility.audio = new Map();
myUtility.images = new Map();
myUtility.imagesOriginSize = new Map();
// 坐标原点 包含缩放
myUtility.originX = 0;
myUtility.originY = 0;
myUtility.setOrigin = (x, y)=>{
myUtility.originX = x;
myUtility.originY = y;
}
myUtility.getOrigin = ()=>{
return {
x: myUtility.originX,
y: myUtility.originY
}
}
// 坐标原点 包含缩放
myUtility.relativeOriginX = 0;
myUtility.relativeOriginY = 0;
myUtility.setRelativeOrigin = (x, y)=>{
myUtility.relativeOriginX = x;
myUtility.relativeOriginY = y;
}
myUtility.getRelativeOrigin = ()=>{
return {
x: myUtility.relativeOriginX,
y: myUtility.relativeOriginY
}
}
// 存放音乐和图片的地址
const audioObj = {}
const imageObj = {}
// 添加音乐
myUtility.audio.add = ( key, url ) => {
audioObj[key] = url
};
// 添加音乐
myUtility.images.add = ( key, url ) => {
imageObj[key] = url
};
// 播放音乐
myUtility.audio.playAudio = function(key, now = false, callback = null) {
const audio = myUtility.audio.get(key);
if (audio) {
if (now) {
audio.pause();
audio.currentTime = 0;
}
if (callback) {
audio.onended = () => {
callback();
};
}
audio.play();
}
}
// 异步加载图片 音频资源
myUtility.loadResources = ()=> {
const pr = [];
for(let key in imageObj){
const p = preloadImage(imageObj[key]).then(img => {
myUtility.images.set(key, img);
myUtility.imagesOriginSize.set(key, {width:img.width, height:img.height});
}).catch(err => console.log(key));
pr.push(p);
};
for(let key in audioObj){
const a = preloadAudio(audioObj[key]).then((music) => {
myUtility.audio.set(key, music);
}).catch(err => console.log(key));
pr.push(a);
};
return Promise.all(pr);
}
// 预加载图片
const preloadImage = (url) => {
return new Promise((resolve, reject) => {
const img = new Image();
img.src = url;
img.onload = () => resolve(img);
img.onerror = reject;
img.src = url;
});
}
// 预加载音频
const preloadAudio = (url) => {
return new Promise((resolve, reject) => {
const audio = new Audio();
audio.oncanplay = a => {
resolve(audio);
};
audio.onerror = () => {
reject();
};
audio.src = url;
audio.load();
});
}
// 缓存页面元素
myUtility.cartoonElementsBuffer = {}
myUtility.createCartoonElement = (key, element, width, heigth, initX, initY)=>{
myUtility.cartoonElementsBuffer[key] = {}
myUtility.cartoonElementsBuffer[key].id = key;
myUtility.cartoonElementsBuffer[key].width = width;
myUtility.cartoonElementsBuffer[key].heigth = heigth;
myUtility.cartoonElementsBuffer[key].initX = initX;
myUtility.cartoonElementsBuffer[key].initY = initY;
myUtility.cartoonElementsBuffer[key].ref = element;
return myUtility.cartoonElementsBuffer[key]
}
myUtility.getCartoonElementRef = (key)=>{
if(myUtility.cartoonElementsBuffer[key]){
return myUtility.cartoonElementsBuffer[key].ref;
}else{
return undefined
}
}
myUtility.getCartoonElement = (key)=>{
return myUtility.cartoonElementsBuffer[key]
}
myUtility.setCartoonElementPosition = (key, posi)=>{
myUtility.cartoonElementsBuffer[key].ref.x = posi.x
myUtility.cartoonElementsBuffer[key].ref.y = posi.y
myUtility.cartoonElementsBuffer[key].x = posi.x
myUtility.cartoonElementsBuffer[key].y = posi.y
}
myUtility.setCartoonElementPositionX = (key, x)=>{
myUtility.cartoonElementsBuffer[key].ref.x = x
myUtility.cartoonElementsBuffer[key].x = x
}
myUtility.setCartoonElementRelativePositionX = (key, x)=>{
myUtility.cartoonElementsBuffer[key].relativeX = x
}
myUtility.setCartoonElementPositionY = (key, y)=>{
myUtility.cartoonElementsBuffer[key].ref.y = y
myUtility.cartoonElementsBuffer[key].y = y
}
myUtility.setCartoonElementRelativePositionY = (key, y)=>{
myUtility.cartoonElementsBuffer[key].relativeY = y
}
myUtility.getCartoonElementPosition = (key)=>{
return {
x: myUtility.cartoonElementsBuffer[key].x,
y: myUtility.cartoonElementsBuffer[key].y
}
}
myUtility.getCartoonElementRelativePosition = (key)=>{
return {
x: myUtility.cartoonElementsBuffer[key].relativeX,
y: myUtility.cartoonElementsBuffer[key].relativeY
}
}
myUtility.animation = {}
myUtility.animation.move = (eleKey, distPosition, runTime, callback )=>{
tweenChange(myUtility.cartoonElementsBuffer[eleKey].ref, distPosition, runTime, ()=>{
callback && callback()
});
}
myUtility.animation.scaleChange = myUtility.animation.move;
export default myUtility
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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