Commit 22ec6f5d authored by 李维's avatar 李维

Dev commit

parent 732bff8a
......@@ -188,6 +188,7 @@ export class PlayComponent implements OnInit, OnDestroy {
initGame(){
console.log(this.g_formData);
this.createTestLabel();
this.initTitle_Part();
this.initTitle_Main();
......@@ -285,32 +286,31 @@ export class PlayComponent implements OnInit, OnDestroy {
}
initSlider() {
const _this = this
const updateSlider = function(len) {
let top = _this.g_cartoon.getCartoonElement("slider-top");
let body = _this.g_cartoon.getCartoonElement("slider-body");
let bottom = _this.g_cartoon.getCartoonElement("slider-bottom");
const updateSlider = (len) => {
let top = this.g_cartoon.getCartoonElement("slider-top");
let body = this.g_cartoon.getCartoonElement("slider-body");
let bottom = this.g_cartoon.getCartoonElement("slider-bottom");
body.update(len);
top.update();
bottom.update();
}
const setProgress = function(scale) {
const setProgress = (scale) => {
sliderBG.currentProgress = scale;
let scrollPannel = _this.g_cartoon.getCartoonElement("scroll-pannel")
let scrollPannel = this.g_cartoon.getCartoonElement("scroll-pannel")
let totalHeight = 546;
let pix = totalHeight / sliderBG.fullHeight;
let empty = (sliderBG.fullHeight - sliderBG.winHeight) * scale * pix;
let top = _this.g_cartoon.getCartoonElement("slider-top");
let body = _this.g_cartoon.getCartoonElement("slider-body");
let bottom = _this.g_cartoon.getCartoonElement("slider-bottom");
let top = this.g_cartoon.getCartoonElement("slider-top");
let body = this.g_cartoon.getCartoonElement("slider-body");
let bottom = this.g_cartoon.getCartoonElement("slider-bottom");
let bb = body.ref.getBoundingBox()
body.ref.y = -282 + empty + 4 + bb.height / 2;
top.update();
bottom.update();
scrollPannel.ref.y = 78 * _this.g_mapScale - (scrollPannel.currentY - (_this.g_canvasHeight - 78 * _this.g_mapScale)) * sliderBG.currentProgress;
scrollPannel.ref.y = 78 * this.g_mapScale - (scrollPannel.currentY - (this.g_canvasHeight - 78 * this.g_mapScale)) * sliderBG.currentProgress;
}
let sliderBG = this.g_cartoon.createCartoonElementImageFunc("slider-background", "bgSlider", (w, h)=>{
......@@ -480,12 +480,23 @@ export class PlayComponent implements OnInit, OnDestroy {
pannel.windowHeight = this.g_canvasHeight - 78 * this.g_mapScale
pannel.currentY = 32;
pannel.currentQuestionIndex = 0;
pannel.insertQuestion = (text) => {
pannel.insertQuestion = (text, nextQuestion = false) => {
if(nextQuestion) {
pannel.currentQuestionIndex++;
let label = this.g_cartoon.createCartoonElementLabel("lebel-question-" + pannel.currentQuestionIndex, `${pannel.currentQuestionIndex}. ${text}`, "GOTHICB_1", "#000000", 36 * this.g_mapScale)
let bb = label.ref.getBoundingBox()
label.ref.x = 42 * this.g_mapScale + bb.width / 2;
label.ref.y = pannel.currentY + 64 * this.g_mapScale / 2;
}
let textString = ""
let startX = 42 * this.g_mapScale;
if(nextQuestion) {
textString = `${pannel.currentQuestionIndex}. ${text}`;
} else {
textString = text;
pannel.currentY -= 52 * this.g_mapScale;
startX += 42 * this.g_mapScale;
}
let lineText = this.creatQuestionTextLine(pannel.currentQuestionIndex, textString, startX, pannel.currentY, pannel.ref)
let label = lineText.label;
lineText.show()
pannel.currentY = label.ref.y + 64 * this.g_mapScale;
if(pannel.windowHeight < pannel.currentY) {
pannel.ref.setSize(this.g_canvasWidth, pannel.currentY)
......@@ -498,18 +509,19 @@ export class PlayComponent implements OnInit, OnDestroy {
pannel.firstInstert = true;
pannel.insertAnswer = (text) => {
let label = this.g_cartoon.createCartoonElementLabel("lebel-answer-" + pannel.currentQuestionIndex, text, "DFChu-W4-WIN-BF", "#d60d00", 42 * this.g_mapScale)
let bb = label.ref.getBoundingBox()
let line = this.creatAnswerTextLine(pannel.currentQuestionIndex, text, 42 * this.g_mapScale * 2, pannel.currentY, pannel.ref)
let label = line.label
let bb = label.ref.getBoundingBox();
label.ref.x = 42 * this.g_mapScale * 2 + bb.width / 2;
if(pannel.lastInserType == "Q") {
pannel.currentY -= 32 * this.g_mapScale
line.mask.ref.y -= 32 * this.g_mapScale;
}
label.ref.y = pannel.currentY + 32 * this.g_mapScale / 2;
if(pannel.firstInstert) {
label.ref.x += 21 * this.g_mapScale;
pannel.firstInstert = false;
}
pannel.currentY = label.ref.y + 32 * this.g_mapScale;
line.show()
if(pannel.windowHeight < pannel.currentY) {
pannel.ref.setSize(this.g_canvasWidth, pannel.currentY)
this.g_cartoon.getCartoonElement("slider-background").initSlider(pannel.windowHeight, pannel.currentY, 1)
......@@ -548,18 +560,150 @@ export class PlayComponent implements OnInit, OnDestroy {
const scrollPannel = this.g_cartoon.getCartoonElement("scroll-pannel")
this.subscribeMapDownEvent(btnQuestion.id, ()=>{
scrollPannel.insertQuestion("Where is Mandy and Carl’s backyard?")
let text = "Where is Mandy and Carl’s backyard?Where is Mandy and Carl’s backyard?Where is Mandy and Carl’s backyard?"
let textArray = this.stringToArray(text, 56)
let lastIndex = textArray.length
textArray.forEach((item, index) => {
console.log(item.id)
if(index==0) {
setTimeout(() => {
scrollPannel.insertQuestion(item, true)
if(index == lastIndex-1) {
this.g_enableMapDown = true;
}
}, 0);
} else {
setTimeout(() => {
scrollPannel.insertQuestion(item, false);
if(index == lastIndex-1) {
this.g_enableMapDown = true;
}
}, 900*index);
}
})
})
this.subscribeMapDownEvent(btnAnswer.id, ()=>{
scrollPannel.insertAnswer("It is behind there house.")
let text = "It is behind there house.It is behind there house.It is behind there house.It is behind there house.It is behind there house.It is behind there house.It is behind there house."
let textArray = this.stringToArray(text, 56)
let lastIndex = textArray.length
textArray.forEach((item, index) => {
console.log(item.id)
setTimeout(() => {
scrollPannel.insertAnswer(item);
if(index == lastIndex-1) {
this.g_enableMapDown = true;
}
}, 900*index);
})
})
this.render(btnQuestion.ref, zIndexMap.buttons);
this.render(btnAnswer.ref, zIndexMap.buttons);
}
creatQuestionTextLine(index, text, startX, startY, parent) {
let line = {
label: null,
show: null
}
line.label = this.g_cartoon.createCartoonElementLabel(`lebel-question-${index}`, text, "GOTHICB_1", "#000000", 36 * this.g_mapScale);
let bb = line.label.ref.getBoundingBox()
line.label.ref.x = startX + bb.width / 2;
line.label.ref.y = startY + 64 * this.g_mapScale / 2;
let mask = this.g_cartoon.createCartoonElementShapeRect(`lebel-question-${index}-mask`, this.g_canvasWidth, 64 * this.g_mapScale, "#f0f5f8") // f0f5f8
mask.ref.x = startX
mask.ref.y = startY
line.show = () => {
tweenChange(mask.ref, {x: this.g_canvasWidth}, 1)
}
parent.addChild(line.label.ref);
parent.addChild(mask.ref);
return line
}
creatAnswerTextLine(index, text, startX, startY, parent) {
let line = {
label: null,
mask: null,
show: null
}
line.label = this.g_cartoon.createCartoonElementLabel(`lebel-answer-${index}`, text, "DFChu-W4-WIN-BF", "#d60d00", 42 * this.g_mapScale);
let bb = line.label.ref.getBoundingBox()
line.label.ref.x = startX + bb.width / 2;
line.label.ref.y = startY + 64 * this.g_mapScale / 2;
let mask = this.g_cartoon.createCartoonElementShapeRect(`lebel-answer-${index}-mask`, this.g_canvasWidth, 64 * this.g_mapScale, "#f0f5f8") // f0f5f8
mask.ref.x = startX
mask.ref.y = startY
line.mask = mask;
line.show = () => {
tweenChange(mask.ref, {x: this.g_canvasWidth}, 1)
}
parent.addChild(line.label.ref);
parent.addChild(mask.ref);
return line
}
stringToArray(text, maxLen) {
const cutString = (str, len) => {
let arr = str.split("")
let a = arr.splice(0, len)
return {
a: a.join(""),
b: arr.join("")
}
}
let s = text
let textArray = []
do {
let cut = cutString(s, maxLen)
s = cut.b
textArray.push(cut.a)
} while(maxLen < s.length)
if(s.length != 0) {
textArray.push(s)
}
return textArray
}
createTestLabel() {
let testLabel = this.g_cartoon.createCartoonElementLabel(`test-label`, "TEST_YOU_CANT_SEE_THIS", "DFChu-W4-WIN-BF", "#d60d00", 42 * this.g_mapScale);
this.render(testLabel.ref)
}
......
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