Commit 2996131e authored by 李维's avatar 李维

dev commit

parent 8700dbcc
......@@ -266,24 +266,39 @@ export class Cartoon {
return this.cartoonElementsBuffer[id]
}
createLabel = ({
text,
fontName,
fontColor,
fontSize,
textAlign
}, initX?, initY?)=>{
createLabel = ( text, fontName, fontColor, fontSize, initX?, initY? )=>{
let element = new Label()
element.text = text;
if(fontName){
element.fontName = fontName;
}
if(fontColor){
element.fontColor = fontColor;
}
if(fontSize){
element.fontSize = fontSize;
element.textAlign = textAlign;
}
element.textAlign = "center";
element.x = initX;
element.y = initY;
return element
}
createImage(image, callbackScale, callbackPosition ){
let element = new MySprite()
element.init(this.images.get(image))
let scale = callbackScale(element.width, element.height)
let position = callbackPosition(element.width, element.height)
element.scaleX = scale.sx
element.scaleY = scale.sy
element.x = position.x
element.y = position.y
return element
}
getCartoonElementRef = (key)=>{
if(this.cartoonElementsBuffer[key]){
return this.cartoonElementsBuffer[key].ref;
......@@ -337,6 +352,7 @@ export class Cartoon {
setCartoonElementRelativePositionY = (key, y)=>{
this.cartoonElementsBuffer[key].relativeY = y
}
getCartoonElementPosition = (key)=>{
return {
x: this.cartoonElementsBuffer[key].x,
......
......@@ -215,7 +215,6 @@ export class PlayComponent implements OnInit, OnDestroy {
// ------------------------------------------------------------------------------
initGame(){
console.log(this.g_formData)
this.initBackground();
this.initRoll();
this.initLights()
......@@ -299,6 +298,7 @@ export class PlayComponent implements OnInit, OnDestroy {
this.subscribeMapDownEvent(element.id, ()=>{
if(this.m_enableCamera){
this.m_enableCamera = false;
clearTimeout(this.m_autoFocusID)
this.g_cartoon.playAudio("sm-camera")
this.g_cartoon.getCartoonElement(`card-show`).show(()=>{
this.g_enableMapDown = true
......@@ -357,6 +357,26 @@ export class PlayComponent implements OnInit, OnDestroy {
let cardContent = this.g_cartoon.createCartoonElementImage(`card-content-${index}`, "Image-05", 210, 210, 0, 0)
element.ref.addChild(cardContent.ref)
if(data.type=="Image"){
let cardImage = this.g_cartoon.createImage(data.image_url, (w,h)=>{
let sx = 200 / w;
let sy = 200 / h;
return {
sx: Math.min(sx,sy),
sy: Math.min(sx,sy)
}
}, (w,h)=>{
return {
x: 0,
y:0
}
})
element.ref.addChild(cardImage)
}else{
let cardText = this.g_cartoon.createLabel(data.text, null, null, 20)
element.ref.addChild(cardText)
}
// 高亮
let cardContentHighlight = this.g_cartoon.createCartoonElementImage(`card-content-highlight-${index}`, "card-hightlight", 256, 285, 5, -4)
cardContentHighlight.ref.alpha = 0;
......@@ -451,13 +471,11 @@ export class PlayComponent implements OnInit, OnDestroy {
}
if(this.g_cartoon.getCartoonElement(this.m_allCardIds[next]).ref.x>=this.g_canvasWidth-300*this.g_mapScale){
this.g_enableMapDown = false;
this.cardRunControl(500*this.g_mapScale, ()=>{
if(current != -1){
this.g_cartoon.getCartoonElement(this.m_allCardIds[current]).hideHighlight()
}
this.g_cartoon.getCartoonElement(this.m_allCardIds[next]).showHighlight(()=>{
this.g_enableMapDown = true;
callback && callback()
})
this.m_currentFocusCard = next;
......@@ -476,9 +494,13 @@ export class PlayComponent implements OnInit, OnDestroy {
autoRunFocus(){
if(this.m_enableAutoRunFocus){
this.nextFocus(()=>{
if(this.m_enableAutoRunFocus){
this.m_autoFocusID = setTimeout(()=>{
if(this.m_enableAutoRunFocus){
this.autoRunFocus()
}
},3000)
}
})
}
}
......@@ -504,23 +526,89 @@ export class PlayComponent implements OnInit, OnDestroy {
let cardHighlight = this.g_cartoon.createCartoonElementImage(`card-highlight`, "highlight", 439*0.7, 408*0.7, 0, 0)
element.ref.children.unshift(cardHighlight.ref)
let clickTarget = this.g_cartoon.createCartoonElementImage(`card-click-target`, "Image-05", 170, 170, 0, 0)
clickTarget.ref.alpha = 0;
element.ref.addChild(clickTarget.ref)
let textContent = this.g_cartoon.createLabel("", null, null, 20)
let imageContent = this.g_cartoon.createImage("Image-05", (w,h)=>{
let sx = 170 / w;
let sy = 170 / h;
return {
sx: Math.min(sx,sy),
sy: Math.min(sx,sy)
}
}, (w,h)=>{
return {
x: 0,
y:0
}
})
element.textContent = textContent;
element.imageContent = imageContent;
element.audio_url = null
element.setContent = (data)=>{
if(data.type=="Image"){
element.imageContent = this.g_cartoon.createImage(data.image_url, (w,h)=>{
let sx = 170 / w;
let sy = 170 / h;
return {
sx: Math.min(sx,sy),
sy: Math.min(sx,sy)
}
}, (w,h)=>{
return {
x: 0,
y:0
}
})
element.ref.addChild(element.imageContent)
}else{
element.textContent = this.g_cartoon.createLabel(data.text, null, null, 20)
element.ref.addChild(element.textContent)
}
if(data.audio_url){
element.audio_url = data.audio_url
}
}
element.show = (callback?)=>{
element.setContent(this.g_formData.dataArray[this.m_currentFocusCard])
element.ref.visible = true;
this.m_enableAutoRunFocus = false
clearTimeout(this.m_autoFocusID)
tweenChange(element.ref, {scaleX: element.ref.initScaleX, scaleY: element.ref.initScaleY}, 0.3, ()=>{
this.g_cartoon.playAudio(element.audio_url)
callback && callback()
})
}
element.hide = (callback?)=>{
this.m_enableAutoRunFocus = true;
element.audio_url = null;
this.g_cartoon.stopAudio(element.audio_url)
this.autoRunFocus()
tweenChange(element.ref, {scaleX: 0, scaleY: 0}, 0.3, ()=>{
element.ref.visible = false;
let textIndex = element.ref.children.indexOf(element.textContent)
let imageIndex = element.ref.children.indexOf(element.imageContent)
if(textIndex!=-1){
element.ref.children.splice(textIndex,1)
}
if(imageIndex!=-1){
element.ref.children.splice(imageIndex,1)
}
callback && callback()
})
}
this.subscribeMapDownEvent(clickTarget.id, ()=>{
this.g_cartoon.stopAudio(element.audio_url)
this.g_cartoon.playAudio(element.audio_url)
this.g_enableMapDown = true;
})
this.subscribeMapDownEvent(closeBntton.id, ()=>{
this.g_cartoon.playAudio("sm-camera")
element.hide(()=>{
......@@ -816,7 +904,6 @@ runWaterLights(totalLightCount){
}
mapMove(event) {
// console.log(this.g_clickX, this.g_clickY)
let myStopPropagation = false;
if (!this.g_enableMapMove) {
return;
......
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