Commit a1c07225 authored by 李维's avatar 李维

dev commit

parent 0fad37c7
......@@ -177,12 +177,13 @@ export class PlayComponent implements OnInit, OnDestroy {
// ------------------------------------------------------------------------------
initGame(){
console.log(this.g_formData)
this.initBackground()
this.initXuanZhuanTai()
this.initTable()
this.initShowWindow()
this.initCard_up()
console.log(this.g_formData);
this.initBackground();
this.initXuanZhuanTai();
this.initTable();
this.initShowWindow();
this.initCard_up();
this.initCard_down();
}
cleanGameVar(){
......@@ -606,9 +607,6 @@ export class PlayComponent implements OnInit, OnDestroy {
}
initCard_up(){
let xuanzhuanTai = this.g_cartoon.getCartoonElement("XuanZhuanTai")
let cardAll = []
this.g_formData.textUp.forEach(item => {
......@@ -645,6 +643,9 @@ export class PlayComponent implements OnInit, OnDestroy {
let lastWidth = 0
let cardX = xuanzhuanTai.ref.x - (xuanzhuanTai.ref.width*this.g_mapScale)/2 + 100 * this.g_mapScale
let A1 = []
let A2 = []
let A3 = []
cardAll.forEach((card, index)=>{
let pos = {x:0, y:0}
if(index!=0){
......@@ -659,9 +660,18 @@ export class PlayComponent implements OnInit, OnDestroy {
cardX = cardX + ((card.width + 20) * this.g_mapScale)/2 + 20 * this.g_mapScale
}
this.createCardUp(index, card, pos)
let temp = this.createCardUp(index, card, pos)
A1.push(temp.e1)
A2.push(temp.e2)
A3.push(temp.e3)
})
let movedDis =this.alignCenter(A1)
A2.forEach(item=>{
item.x = item.x + movedDis
})
A3.forEach(item=>{
item.x = item.x + movedDis
})
}
createCardUp(index, label, pos){
......@@ -698,9 +708,124 @@ export class PlayComponent implements OnInit, OnDestroy {
this.render(panzi, zIndexMap.cardUp)
this.render(card.ref, zIndexMap.cardUp)
this.render(label, zIndexMap.cardUp)
return {
e1: card.ref,
e2: panzi,
e3: label
}
}
initCard_down(){
let table = this.g_cartoon.getCartoonElement("table")
let cardAll = []
this.g_formData.textDown.forEach(item => {
let labelText = this.g_cartoon.createLabel(item.text, "BRLNSR_1", "#634846", 50)
labelText.setScaleXY(this.g_mapScale)
labelText.refreshSize();
cardAll.push(labelText)
});
let spaceing = 10 * this.g_mapScale;
let totalWidth = 0
let totalNum = cardAll.length
cardAll.forEach((element, index) => {
console.log("Label width:" + element.width)
if(index==0 || index==(totalNum-1)){
totalWidth += (element.width/2) + spaceing
}else{
totalWidth += (element.width) + spaceing
}
});
let baseFontsize = 50
let fontSize = 50;
let adjustSX = 1
if(totalWidth > 1700){
fontSize = baseFontsize * (1720 / (totalWidth * 2.2))
}
console.log(totalWidth, fontSize)
cardAll.forEach((card, index)=>{
card.fontSize = fontSize
card.refreshSize()
})
let lastWidth = 0
let cardX = 0
let A1 = []
let A2 = []
cardAll.forEach((card, index)=>{
console.log("===>" + cardX)
let pos = {x:0, y:0}
if(index!=0){
pos = {
x: cardX + ((card.width + 30) * this.g_mapScale)/2, y: table.ref.y - 30 * this.g_mapScale
}
cardX = cardX + (card.width + 30) * this.g_mapScale + 20 * this.g_mapScale
}else{
pos = {
x: cardX + ((card.width + 20) * this.g_mapScale)/2 + 20 * this.g_mapScale, y: table.ref.y - 30 * this.g_mapScale
}
cardX = cardX + ((card.width + 20) * this.g_mapScale)/2 + 20 * this.g_mapScale + ((card.width + 20) * this.g_mapScale)/2 + 20 * this.g_mapScale
}
let temp = this.createCardDown(index, card, pos)
A1.push(temp.e1)
A2.push(temp.e2)
})
let movedDis = this.alignCenter(A1)
A2.forEach(item=>{
item.x = item.x + movedDis
})
}
createCardDown(index, label, pos){
pos.y = pos.y + 20*this.g_mapScale
label.x = pos.x
label.y = pos.y
let card = this.g_cartoon.createCartoonElementImageFunc(`card-down-${index}`, "bg_card_down", (w, h)=>{
return {
sx: (label.width + 20)*this.g_mapScale / w,
sy: 84*this.g_mapScale / h
}
}, (w, h)=>{
return {
x: pos.x,
y: pos.y
}
})
card.text = label;
this.render(card.ref, zIndexMap.cardUp)
this.render(label, zIndexMap.cardUp)
return {
e1: card.ref,
e2: label
}
}
alignCenter(elementArray){
let first = null
let last = null
let length = elementArray.length
if(length > 0){
first = elementArray[0]
}
if(length==1){
last = first
}else{
last = elementArray[length-1]
}
let avDis = ((this.g_canvasWidth - (last.x + last.width/2)) + first.x - first.width/2 ) / 2
let moveDis = avDis - (first.x- first.width/2)
elementArray.forEach(element => {
element.x = element.x + moveDis * this.g_mapScale
});
return moveDis * this.g_mapScale
}
......
......@@ -11,14 +11,19 @@ export default {
// textUp:[
// {text:"make friends", lineTo:""},{text:"lound", lineTo:""},{text:"we eat ice cream", lineTo:""},{text:"very happy", lineTo:""},
// {text:"make friends", lineTo:""},{text:"lound", lineTo:""},{text:"we eat ice cream", lineTo:""},{text:"very happy", lineTo:""},
// {text:"make friends", lineTo:""},{text:"lound", lineTo:""},{text:"we eat ice cream", lineTo:""},{text:"very happy", lineTo:""}
// {text:"make friends", lineTo:""}
// ],
textUp:[
{text:"make friends", lineTo:""},{text:"lound", lineTo:""},{text:"we eat ice cream", lineTo:""},{text:"very happy", lineTo:""},
{text:"make friends", lineTo:""},{text:"lound", lineTo:""},{text:"we eat ice cream", lineTo:""},{text:"very happy", lineTo:""},
{text:"make friends", lineTo:""}
{text:"ABCD", lineTo:""},{text:"ABCDEFG", lineTo:""},{text:"ABCDEF", lineTo:""},{text:"ABCD EFG", lineTo:""},
{text:"ABCD", lineTo:""},{text:"ABCD", lineTo:""},{text:"ABCD", lineTo:""},{text:"ABCD", lineTo:""},
{text:"ABCD", lineTo:""}
],
// textDown:[
// {text:"it's so much fun", lineTo:""},{text:"lound", lineTo:""},{text:"very happy", lineTo:""},{text:"sun", lineTo:""},{text:"at the park", lineTo:""},
// {text:"it's so much fun", lineTo:""},{text:"lound", lineTo:""},{text:"very happy", lineTo:""},{text:"sun", lineTo:""},{text:"at the park", lineTo:""},
// {text:"it's so much fun", lineTo:""}
// ]
textDown:[
{text:"it's so much fun", lineTo:""},{text:"lound", lineTo:""},{text:"very happy", lineTo:""},{text:"sun", lineTo:""},{text:"at the park", lineTo:""}
{text:"it's so much fun", lineTo:""},{text:"lound", lineTo:""},{text:"very happy", lineTo:""},{text:"sun", lineTo:""}
]
}
\ 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