Commit 8ce2c61f authored by 李维's avatar 李维

dev commit

parent 87225b41
...@@ -377,6 +377,10 @@ export class Cartoon { ...@@ -377,6 +377,10 @@ export class Cartoon {
element.scaleY = scale.sy element.scaleY = scale.sy
element.x = position.x element.x = position.x
element.y = position.y element.y = position.y
element.initScaleX = scale.sx
element.initScaleY = scale.sy
element.initX = position.x
element.initY = position.y
return element return element
} }
......
...@@ -46,6 +46,10 @@ export class MySprite extends Sprite { ...@@ -46,6 +46,10 @@ export class MySprite extends Sprite {
childDepandVisible = true; childDepandVisible = true;
childDepandAlpha = false; childDepandAlpha = false;
initScaleX;
initScaleY;
initX;
initY;
img; img;
_z = 0; _z = 0;
......
...@@ -135,7 +135,8 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -135,7 +135,8 @@ export class PlayComponent implements OnInit, OnDestroy {
// ------------ 游戏逻辑数据 ------------ // ------------ 游戏逻辑数据 ------------
m_startGame = false; m_startGame = false;
m_allDrums = [] m_allDrums = [];
m_dataArrayNew = []
// ------------------------------------ // ------------------------------------
...@@ -223,8 +224,9 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -223,8 +224,9 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
restartGame(){ restartGame(){
this.cleanGameVar() this.cleanGameVar();
this.startGame() this.startGame();
this.initDrum();
} }
endGame(){ endGame(){
...@@ -263,7 +265,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -263,7 +265,7 @@ export class PlayComponent implements OnInit, OnDestroy {
}) })
this.render(bg_Desk.ref, zIndexMap.mainDesk) this.render(bg_Desk.ref, zIndexMap.mainDesk)
let bg_Light = this.g_cartoon.createCartoonElementImageFunc("main-background-desk", "dengqiu1", (w ,h)=>{ let bg_Light = this.g_cartoon.createCartoonElementImageFunc("main-background-light", "dengqiu1", (w ,h)=>{
return { return {
sx: 1032 * this.g_mapScale / w, sx: 1032 * this.g_mapScale / w,
sy: 317 * this.g_mapScale / h sy: 317 * this.g_mapScale / h
...@@ -726,7 +728,8 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -726,7 +728,8 @@ export class PlayComponent implements OnInit, OnDestroy {
this.g_canvasWidth / 2 - (317 / 2) * 3 * this.g_mapScale this.g_canvasWidth / 2 - (317 / 2) * 3 * this.g_mapScale
] ]
this.g_formData.dataArray.forEach((item, index) => { this.m_dataArrayNew = this.randomArray_shuffle(this.g_formData.dataArray)
this.m_dataArrayNew.forEach((item, index) => {
let element = this.createDrum(index, item, baseX[totalDrumNum]) let element = this.createDrum(index, item, baseX[totalDrumNum])
this.m_allDrums.push(element.id) this.m_allDrums.push(element.id)
this.render(element.ref, zIndexMap.drum) this.render(element.ref, zIndexMap.drum)
...@@ -768,6 +771,61 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -768,6 +771,61 @@ export class PlayComponent implements OnInit, OnDestroy {
element.handSide = "right" element.handSide = "right"
} }
element.content = null;
if(data.type == "Image"){
element.imageContainer = this.g_cartoon.createImage("card_bg", (w, h)=>{
return {
sx: 261 / w,
sy: 178 / h
}
}, (w, h)=>{
return {
x: 0,
y: 60
}
})
element.imageContainer.visible = false;
element.imageContainer.setScaleXY(0)
element.content = element.imageContainer
element.ref.addChild(element.imageContainer)
element.image = this.g_cartoon.createImage(data.image_url, (w, h)=>{
let sx = 261 / w
let sy = 178 / w
let s = Math.min(sx, sy)
return {
sx: s,
sy: s
}
}, (w, h)=>{
return {
x: 0,
y: 0
}
})
element.imageContainer.addChild(element.image)
}else{
element.textContainer = this.g_cartoon.createImage("card_bg", (w, h)=>{
return {
sx: 261 / w,
sy: 178 / h
}
}, (w, h)=>{
return {
x: 0,
y: 60
}
})
element.textContainer.visible = false;
element.textContainer.setScaleXY(0)
element.content = element.textContainer
element.ref.addChild(element.textContainer)
element.text = this.g_cartoon.createLabel(data.text, "GOTHICB_1", "#FF0", 32)
element.textContainer.addChild(element.text)
}
element.highlight = () => { element.highlight = () => {
this.m_setTimeoutIDs.push(setTimeout(() => { this.m_setTimeoutIDs.push(setTimeout(() => {
this.g_cartoon.getCartoonElement("boy").beatReset() this.g_cartoon.getCartoonElement("boy").beatReset()
...@@ -782,19 +840,22 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -782,19 +840,22 @@ export class PlayComponent implements OnInit, OnDestroy {
element.isOpen = false; element.isOpen = false;
this.subscribeMapDownEvent(element.id, ()=>{ this.subscribeMapDownEvent(element.id, ()=>{
if(!this.m_startGame){ if(!this.m_startGame || element.isOpen){
this.g_enableMapDown = true; this.g_enableMapDown = true;
return return
} }
this.setRenderZIndex(element.ref, zIndexMap.drum + 1) this.setRenderZIndex(element.ref, zIndexMap.drum + 1)
tweenChange(element.ref, {scaleX: element.initScaleX * 1.2, scaleY: element.initScaleY * 1.2}, 0.2, ()=>{ tweenChange(element.ref, {scaleX: element.initScaleX * 1.2, scaleY: element.initScaleY * 1.2}, 0.2, ()=>{
if(element.content){
element.content.visible = true;
tweenChange(element.content, {scaleX: element.content.initScaleX, scaleY: element.content.initScaleY}, 0.2)
}
element.light.ref.visible = true; element.light.ref.visible = true;
element.isOpen = true; element.isOpen = true;
this.g_cartoon.getCartoonElement("boy").beat(index, ()=>{ this.g_cartoon.getCartoonElement("boy").beat(index, ()=>{
element.highlight() element.highlight()
}) })
}) })
}) })
return element return element
...@@ -1330,6 +1391,20 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1330,6 +1391,20 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
render(ele, zIndex?:number){ render(ele, zIndex?:number){
// let exist = false;
// let index = 0
// this.m_renderObject.forEach((item, i) => {
// if(item.element.id == ele.id){
// console.warn("Exist in render array!")
// exist = true
// index = i
// }
// });
// if(exist){
// this.m_renderObject.splice(index, 1)
// }
this.m_renderObject.push({element:ele, zIndex:zIndex?zIndex:1}) this.m_renderObject.push({element:ele, zIndex:zIndex?zIndex:1})
this.m_renderObject.sort((a,b)=>{ this.m_renderObject.sort((a,b)=>{
return a.zIndex - b.zIndex return a.zIndex - b.zIndex
......
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