Commit f4f1e030 authored by 李维's avatar 李维

dev commit

parent 56d69ff6
......@@ -38,7 +38,21 @@ import * as _ from "lodash";
import TWEEN from "@tweenjs/tween.js";
const defauleFormData = {
sex:"male"
bgMusic:"FC-Sonw",
dataArray:[
{type:"Image", image_url:"bee-demo", audio_url:"bee-demo"},
{type:"Text", text:"Apple", audio_url:"apple-demo"},
{type:"Image", image_url:"bee-demo", audio_url:"bee-demo"},
{type:"Text", text:"Apple", audio_url:"apple-demo"},
{type:"Image", image_url:"bee-demo", audio_url:"bee-demo"},
{type:"Text", text:"Apple", audio_url:"apple-demo"},
{type:"Image", image_url:"bee-demo", audio_url:"bee-demo"},
{type:"Text", text:"Apple", audio_url:"apple-demo"},
{type:"Image", image_url:"bee-demo", audio_url:"bee-demo"},
{type:"Text", text:"Apple", audio_url:"apple-demo"},
{type:"Image", image_url:"bee-demo", audio_url:"bee-demo"},
{type:"Text", text:"Apple", audio_url:"apple-demo"}
]
}
const zIndexMap = {
......@@ -114,7 +128,8 @@ export class PlayComponent implements OnInit, OnDestroy {
m_enableRunway = false;
m_pickupCard = false;
m_currentPickupCardID = null;
m_allSelectedHotZone = []
m_allSelectedHotZone = [];
m_moveAsstantIntervalId = null
// ------------------------------------
......@@ -180,6 +195,7 @@ export class PlayComponent implements OnInit, OnDestroy {
this.cardRunControl(true)
this.initSelectedCardArea()
this.initStartButton()
this.initBackgroundMusic()
}
cleanGameVar(){
......@@ -198,12 +214,22 @@ export class PlayComponent implements OnInit, OnDestroy {
this.m_pickupCard = false;
this.m_currentPickupCardID = null;
this.m_allSelectedHotZone = []
this.disableMoveAsstant()
}
endGame(){
}
// 播放背景音乐
initBackgroundMusic(){
let play = ()=>{
this.g_cartoon.playAudio(this.g_formData.bgMusic, false, ()=>{
play()
})
}
play()
}
// 背景
initBackground(){
......@@ -299,8 +325,9 @@ export class PlayComponent implements OnInit, OnDestroy {
let boundingBox = this.g_cartoon.getCartoonElement('card-runway').ref.getBoundingBox()
let cardWidth = 244*this.g_mapScale
let cardNumber = Math.ceil(this.g_canvasWidth/cardWidth);
for(let index=0; index<10; index++){
let newCard = this.createCard(index,index*cardWidth,boundingBox.y);
let cardDetailArray = this.g_formData.dataArray
for(let index=0; index<cardDetailArray.length; index++){
let newCard = this.createCard(index,index*cardWidth,boundingBox.y,cardDetailArray[index]);
if(index>=cardNumber){
newCard.ref.x = -999
newCard.waiting = true;
......@@ -313,7 +340,7 @@ export class PlayComponent implements OnInit, OnDestroy {
}
}
createCard(index,x,y){
createCard(index,x,y,data){
this.m_allCardIds.push(`card-bckground-${index}`)
let element = this.g_cartoon.createCartoonElementImageFunc(`card-bckground-${index}`, "bg_card", (w,h)=>{
return {
......@@ -342,49 +369,73 @@ export class PlayComponent implements OnInit, OnDestroy {
})
cardContent.parentID = `card-bckground-${index}`
cardContent.canMove = false;
this.subscribeMapDownEvent(`card-content-${index}`, ()=>{
cardContent.clickTime = null
cardContent.handleClick = ()=>{
this.g_cartoon.playAudio("sm-click")
cardContent.canMove = true;
if(cardContent.parentID){
this.g_cartoon.getCartoonElement(cardContent.parentID).content = null
}
this.enableMoveAsstant(cardContent)
this.m_pickupCard = true;
this.m_currentPickupCardID = `card-content-${index}`
this.g_cartoon.getCartoonElement(`selected-card-hotzone`).show()
this.topOfRenderArray(cardContent.ref)
element.baseClick_x = this.g_clickX
element.baseClick_y = this.g_clickY
}
this.subscribeMapDownEvent(`card-content-${index}`, ()=>{
if( cardContent.parentID.indexOf("hot") != -1 ){
this.g_cartoon.playAudio(data.audio_url)
cardContent.clickTime = new Date().getTime()
}else{
cardContent.handleClick()
}
this.g_enableMapDown = true;
})
this.subscribeMapMoveEvent(`card-content-${index}`, ()=>{
if(cardContent.canMove){
if( cardContent.clickTime ){
let a = cardContent.clickTime - new Date().getTime()
if(Math.abs(a)>50){
cardContent.handleClick()
cardContent.clickTime = null
}
}
if( cardContent.canMove ){
cardContent.ref.x = this.g_clickX
cardContent.ref.y = this.g_clickY
}
// else{
// if(dis>(50*this.g_mapScale)){
// cardContent.canMove = true;
// }
// }
this.g_enableMapMove = true;
})
this.subscribeMapUpEvent(`card-content-${index}`, ()=>{
cardContent.clickTime = null
if(cardContent.canMove){
setTimeout(()=>{
cardContent.canMove = false;
cardContent.backToParent()
this.g_cartoon.getCartoonElement(`selected-card-hotzone`).hide()
this.m_pickupCard = false;
},100)
setTimeout(()=>{
cardContent.canMove = false;
cardContent.backToParent()
this.g_cartoon.getCartoonElement(`selected-card-hotzone`).hide()
this.m_pickupCard = false;
},100)
}else{
if(cardContent.parentID && this.m_currentPickupCardID){
let pickupCard = this.g_cartoon.getCartoonElement(this.m_currentPickupCardID)
if( cardContent.parentID.indexOf("hotzone") != -1 && pickupCard.parentID.indexOf("hotzone") != -1 ){
let temp = pickupCard.parentID
pickupCard.parentID = cardContent.parentID
cardContent.parentID =temp
cardContent.backToParent()
}
if(cardContent.parentID && this.m_currentPickupCardID){
let pickupCard = this.g_cartoon.getCartoonElement(this.m_currentPickupCardID)
if( cardContent.parentID.indexOf("hotzone") != -1 && pickupCard.parentID.indexOf("hotzone") != -1 ){
let temp = pickupCard.parentID
pickupCard.parentID = cardContent.parentID
cardContent.parentID =temp
cardContent.backToParent()
}
}
}
this.disableMoveAsstant()
this.g_enableMapUp = true;
})
element.content = cardContent
......@@ -400,19 +451,26 @@ export class PlayComponent implements OnInit, OnDestroy {
this.render(cardContent.ref,999)
//
let textContainer= new MySprite()
textContainer.init(this.g_cartoon.images.get("text_container"))
textContainer.setScaleXY(150/textContainer.width)
let textContent = new Label()
textContent.text = "T:" + index
textContent.fontColor = "#e05e14";
textContent.fontName = "BerlinSansFBDemi-Bold";
textContent.maxSingalLineWidth = 170*this.g_mapScale
textContent.x = textContent.width/2
textContent.fontSize = 50
textContainer.addChild(textContent)
textContainer.x = -textContainer.width/4
cardContent.ref.addChild(textContainer)
if(data.type == "Text"){
let textContent = new Label()
textContent.text = data.text?data.text:"Demo"
textContent.fontColor = "#e05e14";
textContent.fontName = "BerlinSansFBDemi-Bold";
textContent.textAlign = "center";
textContent.x = textContent.width/2
let textSize = 180*this.g_mapScale / textContent.text.length
if(textSize>50){
textSize = 50
}
textContent.fontSize = textSize
cardContent.ref.addChild(textContent)
}else{
let imageContent = new MySprite()
imageContent.init(this.g_cartoon.images.get(data.image_url?data.image_url:"apple-demp"))
imageContent.setScaleXY(Math.min( 120/imageContent.width, 120/imageContent.height ))
cardContent.ref.addChild(imageContent)
}
element.moveLeft = (distance)=>{
element.ref.x -= distance
......@@ -687,6 +745,19 @@ export class PlayComponent implements OnInit, OnDestroy {
this.render(element.ref)
}
enableMoveAsstant(element){
if(this.m_moveAsstantIntervalId){
clearInterval(this.m_moveAsstantIntervalId)
}
this.m_moveAsstantIntervalId = setInterval(()=>{
element.ref.x = this.g_clickX;
element.ref.y = this.g_clickY;
},50)
}
disableMoveAsstant(){
clearInterval(this.m_moveAsstantIntervalId)
}
......
......@@ -39,9 +39,10 @@ const localImages = {
'bg_title': 'assets/play/bg_title.png',
'bg_card': 'assets/play/bg_card.png',
'bg_card_runway': 'assets/play/bg_card_runway.png',
'text_container': 'assets/play/text_container.png',
'text_container': 'assets/play/text_container-1.png',
'bg_selected_card': 'assets/play/bg_selected_card.png',
'bg_1280_180': 'assets/play/bg_1280_180_1.png'
'bg_1280_180': 'assets/play/bg_1280_180_1.png',
'bee-demo': 'assets/play/bee-demo.jpg'
};
......@@ -68,6 +69,9 @@ const localAudios = {
'change': 'assets/audio/change.mp3',
'selected': 'assets/audio/selected.mp3',
'FC-Sonw': 'assets/audio/FC-Sonw.mp3',
'apple-demo': 'assets/audio/apple-demo.mp3',
'bee-demo': 'assets/audio/bee-demo.mp3'
};
export {localImages, localAudios};
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