Commit db81def0 authored by 李维's avatar 李维

dev commit

parent 371fa080
......@@ -509,6 +509,17 @@ export class Cartoon {
}
}
saveSize(key){
this.cartoonElementsBuffer[key].initX = this.cartoonElementsBuffer[key].ref.x
this.cartoonElementsBuffer[key].initY = this.cartoonElementsBuffer[key].ref.y
this.cartoonElementsBuffer[key].initScaleX = this.cartoonElementsBuffer[key].ref.scaleX
this.cartoonElementsBuffer[key].initScaleY = this.cartoonElementsBuffer[key].ref.scaleX
this.cartoonElementsBuffer[key].ref.initX = this.cartoonElementsBuffer[key].ref.x
this.cartoonElementsBuffer[key].ref.initY = this.cartoonElementsBuffer[key].ref.y
this.cartoonElementsBuffer[key].ref.initScaleX = this.cartoonElementsBuffer[key].ref.scaleX
this.cartoonElementsBuffer[key].ref.initScaleY = this.cartoonElementsBuffer[key].ref.scaleX
}
resetAll = () => {
this.cartoonElementsBuffer = {}
}
......
......@@ -122,6 +122,8 @@ export class PlayComponent implements OnInit, OnDestroy {
// ------------ 游戏逻辑数据 ------------
m_answerCard_All = []
m_questionCard_All = []
m_enableCardMove = false;
m_currentSelectedCardID = null
// ------------------------------------
......@@ -201,7 +203,8 @@ export class PlayComponent implements OnInit, OnDestroy {
this.disableMoveAsstant();
}
}
this.m_currentSelectedCardID = null
this.m_enableCardMove = false;
this.m_answerCard_All = []
this.m_questionCard_All = []
}
......@@ -242,6 +245,9 @@ export class PlayComponent implements OnInit, OnDestroy {
slider.release()
this.disableMoveAsstant();
}
if(this.m_enableCardMove && this.m_currentSelectedCardID){
this.g_cartoon.getCartoonElement(this.m_currentSelectedCardID).release()
}
this.g_enableMapUp = true;
})
......@@ -293,14 +299,15 @@ export class PlayComponent implements OnInit, OnDestroy {
this.m_questionCard_All.push(this.createQuestionCardImage(2, {}))
this.m_questionCard_All.push(this.createQuestionCardImage(3, {}))
this.alignCenter(this.m_questionCard_All, 0, true)
this.alignCenter(this.m_questionCard_All, 40, true)
}
createQuestionCardImage(index, data){
let element = this.g_cartoon.createCartoonElementImageFunc("questioncard-image-"+index, "bg_change2", (w, h)=>{
let element = this.g_cartoon.createCartoonElementImageFunc("questioncard-image-"+index, "lego-building", (w, h)=>{
let s = (155 * this.g_mapScale) / h
return{
sx: (166 * this.g_mapScale) / w,
sy: (185 * this.g_mapScale) / h
sx: s,
sy: s
}
}, (w, h)=>{
return{
......@@ -308,6 +315,139 @@ export class PlayComponent implements OnInit, OnDestroy {
y: this.g_cartoon.getOrigin().y + 720 * this.g_mapScale - 345 * this.g_mapScale
}
})
let imageBD = element.ref.getBoundingBox()
// 边框
let border = this.g_cartoon.createCartoonElementImageFunc("questioncard-image-border-"+index, "image_center", (w, h)=>{
return{
sx: (imageBD.width / element.ref.scaleX) / w,
sy: ((imageBD.height + 26 * this.g_mapScale) / element.ref.scaleY) / h
}
}, (w, h)=>{
return{
x: 0,
y: 13
}
})
element.ref.addChild(border.ref)
let borderLeft = this.g_cartoon.createCartoonElementImageFunc("questioncard-image-border-left-"+index, "image_border_left", (w, h)=>{
return{
sx: (22 / element.ref.scaleX) / w,
sy: ((imageBD.height + 26 * this.g_mapScale) / element.ref.scaleY) / h
}
}, (w, h)=>{
return{
x: -(imageBD.width / element.ref.scaleX) / 2 - 5,
y: 13
}
})
element.ref.addChild(borderLeft.ref)
let borderRight = this.g_cartoon.createCartoonElementImageFunc("questioncard-image-border-right-"+index, "image_border_right", (w, h)=>{
return{
sx: (22 / element.ref.scaleX) / w,
sy: ((imageBD.height + 26 * this.g_mapScale) / element.ref.scaleY) / h
}
}, (w, h)=>{
return{
x: (imageBD.width / element.ref.scaleX) / 2 + 5,
y: 13
}
})
element.ref.addChild(borderRight.ref)
// 高亮边框
let border_H = this.g_cartoon.createCartoonElementImageFunc("questioncard-image-border-h-"+index, "border_center", (w, h)=>{
return{
sx: (imageBD.width / element.ref.scaleX) / w,
sy: ((imageBD.height + 38 * this.g_mapScale) / element.ref.scaleY) / h
}
}, (w, h)=>{
return{
x: 0,
y: 0
}
})
element.ref.addChild(border_H.ref)
let borderLeft_H = this.g_cartoon.createCartoonElementImageFunc("questioncard-image-border-h-left-"+index, "border_left", (w, h)=>{
return{
sx: (22 / element.ref.scaleX) / w,
sy: ((imageBD.height + 38 * this.g_mapScale) / element.ref.scaleY) / h
}
}, (w, h)=>{
return{
x: -(imageBD.width / element.ref.scaleX) / 2 - 20,
y: 3
}
})
element.ref.addChild(borderLeft_H.ref)
let borderRight_H = this.g_cartoon.createCartoonElementImageFunc("questioncard-image-border-h-right-"+index, "border_right", (w, h)=>{
return{
sx: (22 / element.ref.scaleX) / w,
sy: ((imageBD.height + 38 * this.g_mapScale) / element.ref.scaleY) / h
}
}, (w, h)=>{
return{
x: (imageBD.width / element.ref.scaleX) / 2 + 20,
y: 3
}
})
element.ref.addChild(borderRight_H.ref)
border_H.ref.visible = false;
borderRight_H.ref.visible = false;
borderLeft_H.ref.visible = false;
element.startPos = { x:element.initX, y:element.initY }
element.backTo = (pos?, callback?)=>{
if(pos){
tweenChange(element.ref, pos, 0.3, ()=>{
callback && callback()
})
}else{
tweenChange(element.ref, { x:element.initX, y:element.initY }, 0.3, ()=>{
callback && callback()
})
}
}
element.release = ()=>{
this.m_enableCardMove = false;
this.m_currentSelectedCardID = null;
border_H.ref.visible = false;
borderRight_H.ref.visible = false;
borderLeft_H.ref.visible = false;
this.disableMoveAsstant()
element.backTo()
}
this.subscribeMapDownEvent(element.id, ()=>{
this.m_enableCardMove = true;
this.m_currentSelectedCardID = element.id
border_H.ref.visible = true;
borderRight_H.ref.visible = true;
borderLeft_H.ref.visible = true;
this.topOfRenderArray(element.ref)
element.startPos = {
x: this.g_clickX,
y: this.g_clickY
}
this.enableMoveAsstant(()=>{
element.ref.x = this.g_clickX
element.ref.y = this.g_clickY
})
this.g_enableMapDown = true;
})
this.subscribeMapUpEvent(element.id, ()=>{
element.release()
this.g_enableMapUp = true;
})
this.render(element.ref, zIndexMap.questionCard)
return element
......@@ -1362,10 +1502,14 @@ export class PlayComponent implements OnInit, OnDestroy {
elementArray.forEach(element => {
let bd = element.ref.getBoundingBox()
if(withAni){
tweenChange(element.ref, {x: laseX + bd.width / 2}, 0.2)
tweenChange(element.ref, {x: laseX + bd.width / 2}, 0.2, ()=>{
this.g_cartoon.saveSize(element.id)
})
}else{
element.ref.x = laseX + bd.width / 2
this.g_cartoon.saveSize(element.id)
}
laseX = (laseX + bd.width + spacing)
});
}
......
......@@ -50,8 +50,13 @@ const localImages = {
'icon_finishstar': 'assets/play/icon_finishstar.png',
'icon_star': 'assets/play/icon_star.png',
'image_container': 'assets/play/image_container.png',
'image_border_left': 'assets/play/image_border_left.png',
'image_border_right': 'assets/play/image_border_right.png',
'image_center': 'assets/play/image_center.png',
'border_left': 'assets/play/border_left.png',
'border_right': 'assets/play/border_right.png',
'border_center': 'assets/play/border_center.png',
'lego-building': 'assets/play/lego-building.jpg',
'btn_laba (1)': 'assets/play/frame/btn_laba (1).png',
'btn_laba (2)': 'assets/play/frame/btn_laba (2).png',
......@@ -101,7 +106,7 @@ const localAudios = {
'xianshi': 'assets/play/sound/xianshi.mp3',
'xiaolian': 'assets/play/sound/xiaolian.mp3',
'xingxing': 'assets/play/sound/xingxing.mp3',
'default_audio': 'assets/play/sound/Rolling in the deep.mp3',
'default_audio': 'assets/play/sound/Rolling in the deep.mp3'
};
......
......@@ -4,6 +4,6 @@ export default {
question: {
type: "Audio"
},
answerType: "Text",
answerType: "Image",
dataArray: []
}
\ No newline at end of file
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