Commit a43a8344 authored by 李维's avatar 李维

dev commit

parent c1ea66b7
<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>
<div class="preview-box" #wrap style="width: 200px; height: 300px;">
......@@ -19,7 +19,7 @@
</div>
</div>
<div style="float: left; width: 70%">
<div style="float: left; width: 75%">
<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 style="float: left; height: 115px; position: relative; width: 250px; ">
......
......@@ -1458,3 +1458,45 @@ export function shake(item, time = 0.5, callback = null, rate = 1) {
}
// --------------- 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 {
rotateItem,
hideItem,
showItem,
ShapeRectNew
ShapeRectNew,
scaleItem,
showBlingBling
} from "./Unit";
import { localImages, localAudios } from "./resources";
......@@ -104,6 +106,7 @@ export class PlayComponent implements OnInit, OnDestroy {
// ------------ 游戏逻辑数据 ------------
m_puzzleCards_id = []
m_puzzleAnswerCards_id = []
m_currentQuestionIndex = 0;
m_currentMovedCardIndex = -1;
m_totalQusetion = 0;
......@@ -442,6 +445,7 @@ export class PlayComponent implements OnInit, OnDestroy {
let parent = this.g_cartoon.getCartoonElement("quertion-image-container")
hotZoneItemArr.forEach( (item,index) => {
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.scaleX = item.rect.width / (element.ref.width*parent.contentScale)
element.ref.scaleY = item.rect.height / (element.ref.height*parent.contentScale)
......@@ -452,12 +456,13 @@ export class PlayComponent implements OnInit, OnDestroy {
element.ref.alpha = 0;
element.card_audio = item.media.card_audio_url
element.currentClick = false;
element.isPlaced = false;
element.show = ()=>{
tweenChange(element.ref, { alpha:1 } , 0.1)
}
element.click = ()=>{
if(element.card_audio){
if(element.card_audio && element.isPlaced){
this.g_cartoon.stopAllAudio()
this.g_cartoon.playAudio(element.card_audio)
}
......@@ -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`).enableMoveL2 = false;
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`).hide()
this.nextQusetion()
this.g_enableMapUp = true;
this.showBlingStar(element.ref)
}else{
this.g_cartoon.playAudio("sm-choice-incorrect")
let index = this.m_currentMovedCardIndex
......@@ -540,14 +547,14 @@ export class PlayComponent implements OnInit, OnDestroy {
case "large":
containerSize_Width = 193;
containerSize_Height = 193;
cardSize_Width = 140;
cardSize_Height = 140;
cardSize_Width = 120;
cardSize_Height = 120;
break;
case "middle":
containerSize_Width = 148;
containerSize_Height = 148;
cardSize_Width = 125;
cardSize_Height = 125;
cardSize_Width = 120;
cardSize_Height = 120;
break;
case "small":
containerSize_Width = 133;
......@@ -633,7 +640,6 @@ export class PlayComponent implements OnInit, OnDestroy {
return
}
this.m_currentMovedCardIndex = container.cardIndex
// this.g_cartoon.playAudio("sm-click")
container.enableMoveL1= true;
container.activite()
container.click()
......@@ -682,15 +688,27 @@ export class PlayComponent implements OnInit, OnDestroy {
this.m_puzzleCards_id.push(id)
}
addToAnswerCardList(id){
this.m_puzzleAnswerCards_id.push(id)
}
cleanCardList(){
this.m_puzzleCards_id.length = 0;
}
cleanAnswerCardList(){
this.m_puzzleAnswerCards_id.length = 0;
}
cleanGameVar(){
this.m_puzzleCards_id.forEach(card => {
this.g_cartoon.getCartoonElement(card).isPlaced = false;
});
this.m_puzzleAnswerCards_id.forEach(card => {
this.g_cartoon.getCartoonElement(card).isPlaced = false;
});
this.cleanCardList()
this.cleanAnswerCardList()
this.m_totalQusetion = 0;
this.m_currentQuestionIndex = 0;
this.g_cartoon.getCartoonElement("speaker").audio_url = "";
......@@ -1432,4 +1450,14 @@ export class PlayComponent implements OnInit, OnDestroy {
}
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 = {
'petal_1': "assets/play/scrap-pic-1.png",
'petal_2': "assets/play/scrap-pic-2.png",
'petal_3': "assets/play/scrap-pic-3.png",
'star': "assets/play/star.png",
'answer-sheet': "assets/play/AnswerSheet.png",
'baiquan': "assets/play/baiquan.png",
......@@ -33,6 +33,7 @@ const localAudios = {
'sm-click': "assets/audio/sm-click.mp3",
'sm-start': "assets/audio/sm-start.mp3",
'sm-correct': 'assets/audio/sm-correct.mp3',
'star': "assets/audio/star.mp3",
'sm-choice-complete': 'assets/audio/sm-choice-complete.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