Commit a43a8344 authored by 李维's avatar 李维

dev commit

parent c1ea66b7
<div class="p-image-children-editor"> <div class="p-image-children-editor">
<div style="float: left; width: 30%;border-right: 2px solid #ddd; border-bottom: 2px solid #ddd;"> <div style="float: left; width: 25%;border-right: 2px solid #ddd; border-bottom: 2px solid #ddd;">
<h5 style="margin-left: 2.5%;">预览:</h5> <h5 style="margin-left: 2.5%;">预览:</h5>
<div class="preview-box" #wrap style="width: 200px; height: 300px;"> <div class="preview-box" #wrap style="width: 200px; height: 300px;">
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
</div> </div>
</div> </div>
<div style="float: left; width: 70%"> <div style="float: left; width: 75%">
<div nzAlign="middle"> <div nzAlign="middle">
<div class="img-box clearfix" *ngFor="let it of hotZoneArr; let i = index" style="border-bottom: 1px solid #DDD; padding-bottom: 10px;" > <div class="img-box clearfix" *ngFor="let it of hotZoneArr; let i = index" style="border-bottom: 1px solid #DDD; padding-bottom: 10px;" >
<div style="float: left; height: 115px; position: relative; width: 250px; "> <div style="float: left; height: 115px; position: relative; width: 250px; ">
......
...@@ -1458,3 +1458,45 @@ export function shake(item, time = 0.5, callback = null, rate = 1) { ...@@ -1458,3 +1458,45 @@ export function shake(item, time = 0.5, callback = null, rate = 1) {
} }
// --------------- custom class -------------------- // --------------- custom class --------------------
export function showBlingBling(starImg, rectArea, parent, mapScale = 1, num = 30, disTime = 0.1, showTime = 3) {
const timeId = setInterval(() => {
showBlingStar(starImg, num, rectArea, parent, mapScale);
}, disTime * 1000);
setTimeout(() => {
clearInterval(timeId);
}, showTime * 1000);
}
function showBlingStar(starImg, num, rectArea, parent, mapScale) {
for (let i = 0; i < num; i++) {
const star = new MySprite();
star.init(starImg);
const px = -parent.width/2 + Math.random() * parent.width;
const py = -parent.height/2 + Math.random() * parent.height;
star.x = px;
star.y = py;
const randomS = (0.1 + Math.random() * 0.8) * mapScale;
star.setScaleXY(4);
parent.addChild(star);
scaleItem(star, randomS, 0.3, () => {
setTimeout(() => {
scaleItem(star, 0, 0.3, () => {
parent.removeChild(star);
});
}, 100 + Math.random() * 200);
});
}
}
\ No newline at end of file
...@@ -22,7 +22,9 @@ import { ...@@ -22,7 +22,9 @@ import {
rotateItem, rotateItem,
hideItem, hideItem,
showItem, showItem,
ShapeRectNew ShapeRectNew,
scaleItem,
showBlingBling
} from "./Unit"; } from "./Unit";
import { localImages, localAudios } from "./resources"; import { localImages, localAudios } from "./resources";
...@@ -104,6 +106,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -104,6 +106,7 @@ export class PlayComponent implements OnInit, OnDestroy {
// ------------ 游戏逻辑数据 ------------ // ------------ 游戏逻辑数据 ------------
m_puzzleCards_id = [] m_puzzleCards_id = []
m_puzzleAnswerCards_id = []
m_currentQuestionIndex = 0; m_currentQuestionIndex = 0;
m_currentMovedCardIndex = -1; m_currentMovedCardIndex = -1;
m_totalQusetion = 0; m_totalQusetion = 0;
...@@ -442,6 +445,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -442,6 +445,7 @@ export class PlayComponent implements OnInit, OnDestroy {
let parent = this.g_cartoon.getCartoonElement("quertion-image-container") let parent = this.g_cartoon.getCartoonElement("quertion-image-container")
hotZoneItemArr.forEach( (item,index) => { hotZoneItemArr.forEach( (item,index) => {
let element = this.g_cartoon.createCartoonElement("quertion-image-puzzle-"+index, "MySprite") let element = this.g_cartoon.createCartoonElement("quertion-image-puzzle-"+index, "MySprite")
this.addToAnswerCardList("quertion-image-puzzle-"+index)
element.ref.init(this.g_cartoon.images.get(item.media.image_url)) element.ref.init(this.g_cartoon.images.get(item.media.image_url))
element.ref.scaleX = item.rect.width / (element.ref.width*parent.contentScale) element.ref.scaleX = item.rect.width / (element.ref.width*parent.contentScale)
element.ref.scaleY = item.rect.height / (element.ref.height*parent.contentScale) element.ref.scaleY = item.rect.height / (element.ref.height*parent.contentScale)
...@@ -452,12 +456,13 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -452,12 +456,13 @@ export class PlayComponent implements OnInit, OnDestroy {
element.ref.alpha = 0; element.ref.alpha = 0;
element.card_audio = item.media.card_audio_url element.card_audio = item.media.card_audio_url
element.currentClick = false; element.currentClick = false;
element.isPlaced = false;
element.show = ()=>{ element.show = ()=>{
tweenChange(element.ref, { alpha:1 } , 0.1) tweenChange(element.ref, { alpha:1 } , 0.1)
} }
element.click = ()=>{ element.click = ()=>{
if(element.card_audio){ if(element.card_audio && element.isPlaced){
this.g_cartoon.stopAllAudio() this.g_cartoon.stopAllAudio()
this.g_cartoon.playAudio(element.card_audio) this.g_cartoon.playAudio(element.card_audio)
} }
...@@ -492,10 +497,12 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -492,10 +497,12 @@ export class PlayComponent implements OnInit, OnDestroy {
this.g_cartoon.getCartoonElement(`puzzle-card-${index}-container`).enableMoveL1 = false; this.g_cartoon.getCartoonElement(`puzzle-card-${index}-container`).enableMoveL1 = false;
this.g_cartoon.getCartoonElement(`puzzle-card-${index}-container`).enableMoveL2 = false; this.g_cartoon.getCartoonElement(`puzzle-card-${index}-container`).enableMoveL2 = false;
this.g_cartoon.getCartoonElement(`puzzle-card-${index}-container`).isPlaced = true; this.g_cartoon.getCartoonElement(`puzzle-card-${index}-container`).isPlaced = true;
element.isPlaced = true;
this.g_cartoon.getCartoonElement(`puzzle-card-${index}-container`).moveTo(rect.x + rect.width/2, rect.y + rect.height/2) this.g_cartoon.getCartoonElement(`puzzle-card-${index}-container`).moveTo(rect.x + rect.width/2, rect.y + rect.height/2)
this.g_cartoon.getCartoonElement(`puzzle-card-${index}-container`).hide() this.g_cartoon.getCartoonElement(`puzzle-card-${index}-container`).hide()
this.nextQusetion() this.nextQusetion()
this.g_enableMapUp = true; this.g_enableMapUp = true;
this.showBlingStar(element.ref)
}else{ }else{
this.g_cartoon.playAudio("sm-choice-incorrect") this.g_cartoon.playAudio("sm-choice-incorrect")
let index = this.m_currentMovedCardIndex let index = this.m_currentMovedCardIndex
...@@ -540,14 +547,14 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -540,14 +547,14 @@ export class PlayComponent implements OnInit, OnDestroy {
case "large": case "large":
containerSize_Width = 193; containerSize_Width = 193;
containerSize_Height = 193; containerSize_Height = 193;
cardSize_Width = 140; cardSize_Width = 120;
cardSize_Height = 140; cardSize_Height = 120;
break; break;
case "middle": case "middle":
containerSize_Width = 148; containerSize_Width = 148;
containerSize_Height = 148; containerSize_Height = 148;
cardSize_Width = 125; cardSize_Width = 120;
cardSize_Height = 125; cardSize_Height = 120;
break; break;
case "small": case "small":
containerSize_Width = 133; containerSize_Width = 133;
...@@ -633,7 +640,6 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -633,7 +640,6 @@ export class PlayComponent implements OnInit, OnDestroy {
return return
} }
this.m_currentMovedCardIndex = container.cardIndex this.m_currentMovedCardIndex = container.cardIndex
// this.g_cartoon.playAudio("sm-click")
container.enableMoveL1= true; container.enableMoveL1= true;
container.activite() container.activite()
container.click() container.click()
...@@ -682,15 +688,27 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -682,15 +688,27 @@ export class PlayComponent implements OnInit, OnDestroy {
this.m_puzzleCards_id.push(id) this.m_puzzleCards_id.push(id)
} }
addToAnswerCardList(id){
this.m_puzzleAnswerCards_id.push(id)
}
cleanCardList(){ cleanCardList(){
this.m_puzzleCards_id.length = 0; this.m_puzzleCards_id.length = 0;
} }
cleanAnswerCardList(){
this.m_puzzleAnswerCards_id.length = 0;
}
cleanGameVar(){ cleanGameVar(){
this.m_puzzleCards_id.forEach(card => { this.m_puzzleCards_id.forEach(card => {
this.g_cartoon.getCartoonElement(card).isPlaced = false; this.g_cartoon.getCartoonElement(card).isPlaced = false;
}); });
this.m_puzzleAnswerCards_id.forEach(card => {
this.g_cartoon.getCartoonElement(card).isPlaced = false;
});
this.cleanCardList() this.cleanCardList()
this.cleanAnswerCardList()
this.m_totalQusetion = 0; this.m_totalQusetion = 0;
this.m_currentQuestionIndex = 0; this.m_currentQuestionIndex = 0;
this.g_cartoon.getCartoonElement("speaker").audio_url = ""; this.g_cartoon.getCartoonElement("speaker").audio_url = "";
...@@ -1432,4 +1450,14 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1432,4 +1450,14 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
return (radian * Math.PI) / 180; return (radian * Math.PI) / 180;
} }
showBlingStar(element){
let rect = element.getBoundingBox()
showBlingBling(this.g_cartoon.images.get('star'), rect, element, this.g_mapScale, 1, 0.05, 1.5);
}
} }
\ No newline at end of file
...@@ -7,7 +7,7 @@ const localImages = { ...@@ -7,7 +7,7 @@ const localImages = {
'petal_1': "assets/play/scrap-pic-1.png", 'petal_1': "assets/play/scrap-pic-1.png",
'petal_2': "assets/play/scrap-pic-2.png", 'petal_2': "assets/play/scrap-pic-2.png",
'petal_3': "assets/play/scrap-pic-3.png", 'petal_3': "assets/play/scrap-pic-3.png",
'star': "assets/play/star.png",
'answer-sheet': "assets/play/AnswerSheet.png", 'answer-sheet': "assets/play/AnswerSheet.png",
'baiquan': "assets/play/baiquan.png", 'baiquan': "assets/play/baiquan.png",
...@@ -33,6 +33,7 @@ const localAudios = { ...@@ -33,6 +33,7 @@ const localAudios = {
'sm-click': "assets/audio/sm-click.mp3", 'sm-click': "assets/audio/sm-click.mp3",
'sm-start': "assets/audio/sm-start.mp3", 'sm-start': "assets/audio/sm-start.mp3",
'sm-correct': 'assets/audio/sm-correct.mp3', 'sm-correct': 'assets/audio/sm-correct.mp3',
'star': "assets/audio/star.mp3",
'sm-choice-complete': 'assets/audio/sm-choice-complete.mp3', 'sm-choice-complete': 'assets/audio/sm-choice-complete.mp3',
'sm-choice-correct': 'assets/audio/sm-choice-correct.mp3', 'sm-choice-correct': 'assets/audio/sm-choice-correct.mp3',
......
src/assets/play/star.png

1.44 KB | W: | H:

src/assets/play/star.png

1.38 KB | W: | H:

src/assets/play/star.png
src/assets/play/star.png
src/assets/play/star.png
src/assets/play/star.png
  • 2-up
  • Swipe
  • Onion skin
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