Commit b5bd630c authored by wangxin's avatar wangxin

喇叭,文字位置

parent 53d79546
...@@ -34,19 +34,22 @@ ...@@ -34,19 +34,22 @@
}, },
{ {
"__id__": 23 "__id__": 23
},
{
"__id__": 26
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 26 "__id__": 31
}, },
{ {
"__id__": 27 "__id__": 32
} }
], ],
"_prefab": { "_prefab": {
"__id__": 28 "__id__": 33
}, },
"_opacity": 255, "_opacity": 255,
"_color": { "_color": {
...@@ -244,7 +247,7 @@ ...@@ -244,7 +247,7 @@
"__id__": 1 "__id__": 1
}, },
"_children": [], "_children": [],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 7 "__id__": 7
...@@ -1041,6 +1044,198 @@ ...@@ -1041,6 +1044,198 @@
"fileId": "24JopjZG5BJ5D4I5+tuWmu", "fileId": "24JopjZG5BJ5D4I5+tuWmu",
"sync": false "sync": false
}, },
{
"__type__": "cc.Node",
"_name": "btn_sound",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 27
},
{
"__id__": 28
}
],
"_prefab": {
"__id__": 30
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 58,
"height": 66
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
170.428,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 26
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "c872a345-9342-4e8e-a749-4282e347ba91"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.Button",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 26
},
"_enabled": true,
"_normalMaterial": null,
"_grayMaterial": null,
"duration": 0.1,
"zoomScale": 1.2,
"clickEvents": [
{
"__id__": 29
}
],
"_N$interactable": true,
"_N$enableAutoGrayEffect": false,
"_N$transition": 0,
"transition": 0,
"_N$normalColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_N$pressedColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"pressedColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"_N$hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_N$disabledColor": {
"__type__": "cc.Color",
"r": 124,
"g": 124,
"b": 124,
"a": 255
},
"_N$normalSprite": null,
"_N$pressedSprite": null,
"pressedSprite": null,
"_N$hoverSprite": null,
"hoverSprite": null,
"_N$disabledSprite": null,
"_N$target": null,
"_id": ""
},
{
"__type__": "cc.ClickEvent",
"target": {
"__id__": 1
},
"component": "",
"_componentId": "0e35cajgN9JJprFb5rvfFSO",
"handler": "clickTitle",
"customEventData": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "46d02514-75e2-4973-9a0b-bc662330bfb3"
},
"fileId": "6co4fHa1lDoJPOaVKF810W",
"sync": false
},
{ {
"__type__": "cc.Sprite", "__type__": "cc.Sprite",
"_name": "", "_name": "",
......
...@@ -121,7 +121,7 @@ cc.Class({ ...@@ -121,7 +121,7 @@ cc.Class({
getDefaultData() { getDefaultData() {
const dataJson = const dataJson =
'{"title":"test","answer":3,"question":"hello world","options":[{"pic_url":"http://staging-teach.cdn.ireadabc.com/c5a7a94fbebdbf635952454cbe8b3371.jpeg","audio_url":"http://staging-teach.cdn.ireadabc.com/fff5204fc774e932bcd597b4094b0852.mp3","text":"选项1"},{"pic_url":"http://staging-teach.cdn.ireadabc.com/3064a1f8bec54390c031b2c2d8b84e7f.jpeg","audio_url":"http://staging-teach.cdn.ireadabc.com/e8627e7f3ec1a04fdb3660eae81f7636.mp3","text":"选项2"},{"pic_url":"http://staging-teach.cdn.ireadabc.com/3064a1f8bec54390c031b2c2d8b84e7f.jpeg","audio_url":"http://staging-teach.cdn.ireadabc.com/e8627e7f3ec1a04fdb3660eae81f7636.mp3","text":"选项2"},{"pic_url":"http://staging-teach.cdn.ireadabc.com/acd066762f1b2aee555b8fe835bec3ae.jpeg","audio_url":"http://staging-teach.cdn.ireadabc.com/e8627e7f3ec1a04fdb3660eae81f7636.mp3","text":"选项2"}],"audio_title":"http://staging-teach.cdn.ireadabc.com/f7fb9f71ab7d460ac2f78c85efba7610.mp3","audio_question":"http://staging-teach.cdn.ireadabc.com/7934cdcec68eabe639020bad5420d7f8.mp3"}'; '{"title":"test","answer":3,"question":"hello world","options":[{"pic_url":"http://staging-teach.cdn.ireadabc.com/c5a7a94fbebdbf635952454cbe8b3371.jpeg","audio_url":"http://staging-teach.cdn.ireadabc.com/fff5204fc774e932bcd597b4094b0852.mp3","text":"选项1"},{"pic_url":"http://staging-teach.cdn.ireadabc.com/3064a1f8bec54390c031b2c2d8b84e7f.jpeg","audio_url":"http://staging-teach.cdn.ireadabc.com/e8627e7f3ec1a04fdb3660eae81f7636.mp3","text":"选项2"},{"pic_url":"http://staging-teach.cdn.ireadabc.com/3064a1f8bec54390c031b2c2d8b84e7f.jpeg","audio_url":"http://staging-teach.cdn.ireadabc.com/e8627e7f3ec1a04fdb3660eae81f7636.mp3","text":"选项2, how are you doing aaaa"},{"pic_url":"http://staging-teach.cdn.ireadabc.com/acd066762f1b2aee555b8fe835bec3ae.jpeg","audio_url":"http://staging-teach.cdn.ireadabc.com/e8627e7f3ec1a04fdb3660eae81f7636.mp3","text":"选项2"}],"audio_title":"http://staging-teach.cdn.ireadabc.com/f7fb9f71ab7d460ac2f78c85efba7610.mp3","audio_question":"http://staging-teach.cdn.ireadabc.com/7934cdcec68eabe639020bad5420d7f8.mp3"}';
const data = JSON.parse(dataJson); const data = JSON.parse(dataJson);
return data; return data;
}, },
...@@ -200,7 +200,7 @@ cc.Class({ ...@@ -200,7 +200,7 @@ cc.Class({
op.getComponent("option")._isAnswer = true; op.getComponent("option")._isAnswer = true;
} }
op.getComponent("option").setPic(this.data.options[i].pic_url); op.getComponent("option").setPic(this.data.options[i].pic_url);
op.getComponent("option").title.string = this.data.options[i].text; op.getComponent("option").setTitle(this.data.options[i].text);
op.getComponent("option")._audioTitle = this.data.options[i].audio_url; op.getComponent("option")._audioTitle = this.data.options[i].audio_url;
op.getComponent("option")._count = this.data.options.length; op.getComponent("option")._count = this.data.options.length;
this.options.addChild(op); this.options.addChild(op);
......
...@@ -87,6 +87,13 @@ cc.Class({ ...@@ -87,6 +87,13 @@ cc.Class({
}, },
setTitle(title) { setTitle(title) {
console.log("title length " + title.length);
if (title.length <= 14) {
console.log("set center");
this.title.horizontalAlign = cc.Label.HorizontalAlign.CENTER;
} else {
this.title.horizontalAlign = cc.Label.HorizontalAlign.LEFT;
}
this.title.string = title; this.title.string = title;
}, },
......
{
"ver": "2.3.5",
"uuid": "0949203d-2a0f-46ed-9863-184966831b07",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 58,
"height": 66,
"platformSettings": {},
"subMetas": {
"喇叭": {
"ver": "1.0.4",
"uuid": "c872a345-9342-4e8e-a749-4282e347ba91",
"rawTextureUuid": "0949203d-2a0f-46ed-9863-184966831b07",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 58,
"height": 66,
"rawWidth": 58,
"rawHeight": 66,
"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