Commit f3117c31 authored by Tt's avatar Tt

基础页面拼接

parent bd368141
This diff is collapsed.
...@@ -35,152 +35,27 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -35,152 +35,27 @@ export default class SceneComponent extends MyCocosSceneComponent {
} }
initView() { initView() {
this.initBg();
this.initPic();
this.initBtn();
this.initIcon();
} }
initBg() { initListener() {
const bgNode = cc.find('Canvas/bg');
bgNode.scale = this._mapScaleMax;
}
pic1 = null;
pic2 = null;
initPic() {
const canvas = cc.find('Canvas');
const maxW = canvas.width * 0.7;
this.getSprNodeByUrl(this.data.pic_url, (sprNode) => {
const picNode1 = sprNode;
picNode1.scale = maxW / picNode1.width;
picNode1.baseX = picNode1.x;
canvas.addChild(picNode1);
this.pic1 = picNode1;
const labelNode = new cc.Node();
labelNode.color = cc.Color.YELLOW;
const label = labelNode.addComponent(cc.Label);
label.string = this.data.text;
label.fontSize = 60;
label.lineHeight = 60;
label.font = cc.find('Canvas/res/font/BRLNSDB').getComponent('cc.Label').font;
picNode1.addChild(labelNode);
});
this.getSprNodeByUrl(this.data.pic_url_2, (sprNode) => {
const picNode2 = sprNode;
picNode2.scale = maxW / picNode2.width;
canvas.addChild(picNode2);
picNode2.x = canvas.width;
picNode2.baseX = picNode2.x;
this.pic2 = picNode2;
const labelNode = new cc.Node();
const label = labelNode.addComponent(cc.RichText);
const size = 60
label.font = cc.find('Canvas/res/font/BRLNSDB').getComponent(cc.Label).font;
label.string = `<outline color=#751e00 width=4><size=${size}><color=#ffffff>${this.data.text}</color></size></outline>`
label.lineHeight = size;
picNode2.addChild(labelNode);
});
}
initIcon() {
const iconNode = this.getSprNode('icon');
iconNode.zIndex = 5;
iconNode.anchorX = 1;
iconNode.anchorY = 1;
iconNode.parent = cc.find('Canvas');
iconNode.x = iconNode.parent.width / 2 - 10;
iconNode.y = iconNode.parent.height / 2 - 10;
iconNode.on(cc.Node.EventType.TOUCH_START, () => {
this.playAudioByUrl(this.data.audio_url);
})
}
curPage = null;
initBtn() {
this.curPage = 0;
const bottomPart = cc.find('Canvas/bottomPart');
bottomPart.zIndex = 5; // 提高层级
bottomPart.x = bottomPart.parent.width / 2;
bottomPart.y = -bottomPart.parent.height / 2;
const leftBtnNode = bottomPart.getChildByName('btn_left');
//节点中添加了button组件 则可以添加click事件监听
leftBtnNode.on('click', () => {
if (!this._cantouch) {
return;
}
if (this.curPage == 0) {
return;
}
this.curPage = 0
this.leftMove();
this.playLocalAudio('btn');
})
const rightBtnNode = bottomPart.getChildByName('btn_right');
//节点中添加了button组件 则可以添加click事件监听
rightBtnNode.on('click', () => {
if (!this._cantouch) {
return;
}
if (this.curPage == 1) {
return;
}
this.curPage = 1
this.rightMove();
// 游戏结束时需要调用这个方法通知系统作业完成
onHomeworkFinish();
this.playLocalAudio('btn');
})
} }
leftMove() { showData(label_rich, data) {
this._cantouch = false; let list = data.result.sentences[0].details;
const len = this.pic1.parent.width; // 列表处理
cc.tween(this.pic1) let str = "";
.to(1, { x: this.pic1.baseX }, { easing: 'cubicInOut' }) for (let i = 0; i < list.length; i++) {
.start(); let li = list[i];
let s = "";
cc.tween(this.pic2) if (li.overall > 40) {
.to(1, { x: this.pic2.baseX }, { easing: 'cubicInOut' }) s = `<color=#000000>${li.word}</c>`
.call(() => { } else {
this._cantouch = true; s = `<color=#FF0000> ${li.word} </c>`
})
.start();
} }
str += s;
rightMove() {
this._cantouch = false;
const len = this.pic1.parent.width;
cc.tween(this.pic1)
.to(1, { x: this.pic1.baseX - len }, { easing: 'cubicInOut' })
.start();
cc.tween(this.pic2)
.to(1, { x: this.pic2.baseX - len }, { easing: 'cubicInOut' })
.call(() => {
this._cantouch = true;
})
.start();
} }
// update (dt) {}, label_rich.getComponent(cc.RichText).string = str;
initListener() {
} }
playLocalAudio(audioName) { playLocalAudio(audioName) {
......
const { ccclass, property } = cc._decorator;
@ccclass
export default class NewClass extends cc.Component {
// LIFE-CYCLE CALLBACKS:
// onLoad () {}
start() {
let size = cc.winSize;
let base = 1920 / 1080;
let scaleX = cc.winSize.width / cc.winSize.height;
let s = scaleX / base;
this.node.scaleX = s;
}
update(dt) {
}
}
{
"ver": "1.0.8",
"uuid": "b48c8921-d254-40f1-83c0-75ff1761f463",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "2b0b1c4f-6eec-4b6e-a4d2-227b9757f6e6",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 720,
"height": 339,
"platformSettings": {},
"subMetas": {
"img_frame_title": {
"ver": "1.0.4",
"uuid": "5e7bb7e2-6994-408f-85ef-676d6b884a94",
"rawTextureUuid": "2b0b1c4f-6eec-4b6e-a4d2-227b9757f6e6",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 1.5,
"offsetY": 4.5,
"trimX": 10,
"trimY": 0,
"width": 703,
"height": 330,
"rawWidth": 720,
"rawHeight": 339,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "56e7a034-ebd8-42ef-bd02-c0ed4344aa4e",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 169,
"height": 119,
"platformSettings": {},
"subMetas": {
"img_grayarrow_L": {
"ver": "1.0.4",
"uuid": "e622485a-ff44-49e0-80f8-6775291c27d5",
"rawTextureUuid": "56e7a034-ebd8-42ef-bd02-c0ed4344aa4e",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 169,
"height": 119,
"rawWidth": 169,
"rawHeight": 119,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "1729da19-bb76-495c-a249-7ed9cd676b53",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 169,
"height": 119,
"platformSettings": {},
"subMetas": {
"img_grayarrow_R": {
"ver": "1.0.4",
"uuid": "72323746-8cd7-4845-87b4-e318effeefc6",
"rawTextureUuid": "1729da19-bb76-495c-a249-7ed9cd676b53",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 169,
"height": 119,
"rawWidth": 169,
"rawHeight": 119,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "ae113417-7702-4a84-be89-4747f906fb4b",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 510,
"height": 452,
"platformSettings": {},
"subMetas": {
"img_meat": {
"ver": "1.0.4",
"uuid": "2f50d001-ba84-488a-91af-a2a59d99346a",
"rawTextureUuid": "ae113417-7702-4a84-be89-4747f906fb4b",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": -0.5,
"trimX": 2,
"trimY": 1,
"width": 506,
"height": 451,
"rawWidth": 510,
"rawHeight": 452,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "140c29c1-ada0-41bb-b6b3-d1df8464891e",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 986,
"height": 916,
"platformSettings": {},
"subMetas": {
"img_pie": {
"ver": "1.0.4",
"uuid": "fea10748-ae2f-4d2b-be2e-7eef56fc3aaf",
"rawTextureUuid": "140c29c1-ada0-41bb-b6b3-d1df8464891e",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -1.5,
"offsetY": 6.5,
"trimX": 78,
"trimY": 92,
"width": 827,
"height": 719,
"rawWidth": 986,
"rawHeight": 916,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "20866c74-6c41-44e6-88d8-8ce155a8d388",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 169,
"height": 119,
"platformSettings": {},
"subMetas": {
"img_pinkarrow_L": {
"ver": "1.0.4",
"uuid": "9efa8f6f-e5d6-48e9-9628-b0fcdb11795e",
"rawTextureUuid": "20866c74-6c41-44e6-88d8-8ce155a8d388",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 169,
"height": 119,
"rawWidth": 169,
"rawHeight": 119,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "96eae88a-73ef-4826-a048-db02dad54ef1",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 169,
"height": 119,
"platformSettings": {},
"subMetas": {
"img_pinkarrow_R": {
"ver": "1.0.4",
"uuid": "ed620530-f4cd-4f7d-be38-af7e939cdd13",
"rawTextureUuid": "96eae88a-73ef-4826-a048-db02dad54ef1",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 169,
"height": 119,
"rawWidth": 169,
"rawHeight": 119,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "355c9e98-e0bf-4881-89f4-97961b773663",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 1920,
"height": 1080,
"platformSettings": {},
"subMetas": {
"img_table": {
"ver": "1.0.4",
"uuid": "33016275-1369-4c7e-9ff5-31439591dc2c",
"rawTextureUuid": "355c9e98-e0bf-4881-89f4-97961b773663",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 1920,
"height": 1080,
"rawWidth": 1920,
"rawHeight": 1080,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "a2113ccd-d4e3-49dd-8ade-326aa3fd2e64",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 986,
"height": 916,
"platformSettings": {},
"subMetas": {
"img_tableandbread": {
"ver": "1.0.4",
"uuid": "c7c275d7-232e-432e-8db0-33b1d46170d9",
"rawTextureUuid": "a2113ccd-d4e3-49dd-8ade-326aa3fd2e64",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -1.5,
"offsetY": 6.5,
"trimX": 78,
"trimY": 92,
"width": 827,
"height": 719,
"rawWidth": 986,
"rawHeight": 916,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "06ee6fff-3b0d-4570-a121-5461ab7a0a98",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 615,
"height": 433,
"platformSettings": {},
"subMetas": {
"img_vegetables": {
"ver": "1.0.4",
"uuid": "7e516e18-ed2c-47f4-9499-58a5bf7f15b8",
"rawTextureUuid": "06ee6fff-3b0d-4570-a121-5461ab7a0a98",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0.5,
"offsetY": 3,
"trimX": 9,
"trimY": 0,
"width": 598,
"height": 427,
"rawWidth": 615,
"rawHeight": 433,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "223bc9bc-738b-452c-a4d9-e510ea0820aa",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 548,
"height": 428,
"platformSettings": {},
"subMetas": {
"img_wooddish": {
"ver": "1.0.4",
"uuid": "0df2dc75-f406-4b84-84f0-d3c667de15f0",
"rawTextureUuid": "223bc9bc-738b-452c-a4d9-e510ea0820aa",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 3,
"offsetY": 0,
"trimX": 6,
"trimY": 5,
"width": 542,
"height": 418,
"rawWidth": 548,
"rawHeight": 428,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "b4192b24-a6b6-436f-ac59-d2fa1ad535fc",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 595,
"height": 553,
"platformSettings": {},
"subMetas": {
"img_yellowdish": {
"ver": "1.0.4",
"uuid": "beaaf7f9-e5ae-464e-b2bb-43dd9bfc7107",
"rawTextureUuid": "b4192b24-a6b6-436f-ac59-d2fa1ad535fc",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 5,
"trimY": 5,
"width": 585,
"height": 543,
"rawWidth": 595,
"rawHeight": 553,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "2.3.5",
"uuid": "7028c27b-8a83-45a4-8c16-252c028f4737",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 3840,
"height": 2160,
"platformSettings": {},
"subMetas": {
"view": {
"ver": "1.0.4",
"uuid": "f86a8e08-f50c-435c-bcfe-6edb01dd80fc",
"rawTextureUuid": "7028c27b-8a83-45a4-8c16-252c028f4737",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 3840,
"height": 2160,
"rawWidth": 3840,
"rawHeight": 2160,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ 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