Commit 1803ac39 authored by 李维's avatar 李维

修复问题

1. 图片超出边框
2. 卡片一次移动未完成就开始第二次拖动引起的程序异常
3. 适配最多20道题
parent d0fe6be8
......@@ -75,31 +75,31 @@
"__id__": 5
},
{
"__id__": 7
"__id__": 8
},
{
"__id__": 16
"__id__": 17
},
{
"__id__": 26
"__id__": 27
},
{
"__id__": 29
"__id__": 30
},
{
"__id__": 32
"__id__": 33
}
],
"_active": true,
"_components": [
{
"__id__": 36
},
{
"__id__": 37
},
{
"__id__": 38
},
{
"__id__": 39
}
],
"_prefab": null,
......@@ -260,6 +260,9 @@
"_components": [
{
"__id__": 6
},
{
"__id__": 7
}
],
"_prefab": null,
......@@ -342,6 +345,33 @@
"_atlas": null,
"_id": "97/S6HDq9MeqgmV1Zwnhbb"
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 5
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 45,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 1280,
"_originalHeight": 720,
"_id": "29e0TJZt5M/ooP7dZ716YU"
},
{
"__type__": "cc.Node",
"_name": "title",
......@@ -351,19 +381,19 @@
},
"_children": [
{
"__id__": 8
"__id__": 9
}
],
"_active": true,
"_components": [
{
"__id__": 12
},
{
"__id__": 13
},
{
"__id__": 14
},
{
"__id__": 15
}
],
"_prefab": null,
......@@ -419,19 +449,19 @@
"_name": "label",
"_objFlags": 0,
"_parent": {
"__id__": 7
"__id__": 8
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 9
},
{
"__id__": 10
},
{
"__id__": 11
},
{
"__id__": 12
}
],
"_prefab": null,
......@@ -487,7 +517,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 8
"__id__": 9
},
"_enabled": true,
"_materials": [
......@@ -522,7 +552,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 8
"__id__": 9
},
"_enabled": true,
"alignMode": 1,
......@@ -549,7 +579,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 8
"__id__": 9
},
"_enabled": true,
"_color": {
......@@ -567,7 +597,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 7
"__id__": 8
},
"_enabled": true,
"_materials": [
......@@ -599,7 +629,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 7
"__id__": 8
},
"_enabled": true,
"alignMode": 1,
......@@ -626,7 +656,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 7
"__id__": 8
},
"_enabled": true,
"_normalMaterial": null,
......@@ -635,7 +665,7 @@
"zoomScale": 1.2,
"clickEvents": [
{
"__id__": 15
"__id__": 16
}
],
"_N$interactable": true,
......@@ -712,13 +742,13 @@
},
"_children": [
{
"__id__": 17
"__id__": 18
},
{
"__id__": 20
"__id__": 21
},
{
"__id__": 23
"__id__": 24
}
],
"_active": false,
......@@ -776,11 +806,11 @@
"_name": "font",
"_objFlags": 0,
"_parent": {
"__id__": 16
"__id__": 17
},
"_children": [
{
"__id__": 18
"__id__": 19
}
],
"_active": true,
......@@ -838,13 +868,13 @@
"_name": "BRLNSDB",
"_objFlags": 0,
"_parent": {
"__id__": 17
"__id__": 18
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 19
"__id__": 20
}
],
"_prefab": null,
......@@ -900,7 +930,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 18
"__id__": 19
},
"_enabled": true,
"_materials": [],
......@@ -931,11 +961,11 @@
"_name": "img",
"_objFlags": 0,
"_parent": {
"__id__": 16
"__id__": 17
},
"_children": [
{
"__id__": 21
"__id__": 22
}
],
"_active": true,
......@@ -993,13 +1023,13 @@
"_name": "icon",
"_objFlags": 0,
"_parent": {
"__id__": 20
"__id__": 21
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 22
"__id__": 23
}
],
"_prefab": null,
......@@ -1055,7 +1085,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 21
"__id__": 22
},
"_enabled": true,
"_materials": [],
......@@ -1081,11 +1111,11 @@
"_name": "audio",
"_objFlags": 0,
"_parent": {
"__id__": 16
"__id__": 17
},
"_children": [
{
"__id__": 24
"__id__": 25
}
],
"_active": true,
......@@ -1143,13 +1173,13 @@
"_name": "btn",
"_objFlags": 0,
"_parent": {
"__id__": 23
"__id__": 24
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 25
"__id__": 26
}
],
"_prefab": null,
......@@ -1205,7 +1235,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 24
"__id__": 25
},
"_enabled": true,
"_clip": {
......@@ -1230,10 +1260,10 @@
"_active": true,
"_components": [
{
"__id__": 27
"__id__": 28
},
{
"__id__": 28
"__id__": 29
}
],
"_prefab": null,
......@@ -1289,7 +1319,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 26
"__id__": 27
},
"_enabled": true,
"alignMode": 1,
......@@ -1316,7 +1346,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 26
"__id__": 27
},
"_enabled": true,
"_layoutSize": {
......@@ -1354,10 +1384,10 @@
"_active": true,
"_components": [
{
"__id__": 30
"__id__": 31
},
{
"__id__": 31
"__id__": 32
}
],
"_prefab": null,
......@@ -1413,7 +1443,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 29
"__id__": 30
},
"_enabled": true,
"alignMode": 1,
......@@ -1440,7 +1470,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 29
"__id__": 30
},
"_enabled": true,
"_layoutSize": {
......@@ -1478,14 +1508,14 @@
"_active": false,
"_components": [
{
"__id__": 33
"__id__": 34
},
{
"__id__": 34
"__id__": 35
}
],
"_prefab": {
"__id__": 35
"__id__": 36
},
"_opacity": 255,
"_color": {
......@@ -1539,7 +1569,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 32
"__id__": 33
},
"_enabled": true,
"_materials": [
......@@ -1642,7 +1672,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 32
"__id__": 33
},
"_enabled": true,
"alignMode": 1,
......@@ -1667,7 +1697,7 @@
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 32
"__id__": 33
},
"asset": {
"__uuid__": "d30b053b-c7eb-4811-951c-01c98b5825bf"
......@@ -1728,13 +1758,13 @@
},
"_enabled": true,
"title": {
"__id__": 9
"__id__": 10
},
"sounds_container": {
"__id__": 26
"__id__": 27
},
"pic_container": {
"__id__": 29
"__id__": 30
},
"op_sound": {
"__uuid__": "f816bebc-d7fa-41ca-aa93-efe1af15931d"
......@@ -1751,7 +1781,7 @@
}
],
"particle_paper": {
"__id__": 32
"__id__": 33
},
"_opSoundPos": [],
"_opPicPos": [],
......
......@@ -200,10 +200,30 @@ cc.Class({
var self = this;
let scale = 1;
let count = this.data.options.length - 4;
if (count > 0) {
scale = 1 - count * 0.16;
let count = this.data.options.length;
switch(count) {
case 1: scale = 1; break;
case 2: scale = 1; break;
case 3: scale = 1; break;
case 5: scale = 0.85; break;
case 6: scale = 0.7; break;
case 7: scale = 0.6; break;
case 8: scale = 0.5; break;
case 9: scale = 0.45; break;
case 10: scale = 0.4; break;
case 11: scale = 0.37; break;
case 12: scale = 0.35; break;
case 13: scale = 0.32; break;
case 14: scale = 0.3; break;
case 15: scale = 0.28; break;
case 16: scale = 0.26; break;
case 17: scale = 0.24; break;
case 18: scale = 0.22; break;
case 19: scale = 0.2; break;
case 20: scale = 0.18; break;
default: scale = 0.16;
}
this.pic_container.scale = scale;
this.sounds_container.scale = scale;
......@@ -236,9 +256,7 @@ cc.Class({
for (let i = 0; i < this.sounds_container.children.length; i++) {
this.sounds_container.children[i].setPosition(this._opSoundPos[i]);
this.pic_container.children[i].setPosition(this._opPicPos[i]);
this.pic_container.children[i].getComponent("op_pic")._ori_pos = this._opPicPos[i];
this.pic_container.children[i].getComponent("op_pic").setPic();
}
}, 0.5);
......
......@@ -35,14 +35,17 @@ cc.Class({
_height: null,
_isMoved: false,
_scale: 1,
_canMove: true, // 移动开关 防止其他卡片还没有完成移动 就触发了新的卡片移动
},
onEnable() {
cc.game.on("SELECT", this.selected, this);
cc.game.on("MOVE_CONTROL", this.moveControl, this);
},
onDisable() {
cc.game.off("SELECT", this.selected, this);
cc.game.on("MOVE_CONTROL", this.moveControl, this);
},
onLoad() {
......@@ -63,18 +66,12 @@ cc.Class({
this._spriteFrame = frame;
let scale = 1;
if (frameSize.height > 168) {
scale = 168 / frameSize.height;
}
this.pic.spriteFrame = frame;
this.pic.node.width = frameSize.width * scale;
this.pic.node.height = frameSize.height * scale;
let scaleX = cale = 168 / frameSize.width;
let scaleY = cale = 168 / frameSize.height;
scale = scaleX <= scaleY ? scaleX : scaleY
scale = 1;
if (frameSize.width > 168) {
scale = 168 / frameSize.width;
}
this.pic.spriteFrame = frame;
this.pic.node.width = frameSize.width * scale;
this.pic.node.height = frameSize.height * scale;
......@@ -84,12 +81,20 @@ cc.Class({
},
onTouchStart(event) {
if(!this._canMove) {
// 禁止移动
return
}
this.pic_selected.active = true;
cc.game.emit("SELECT", this._opId);
},
//触摸移动;
onTouchMove(touch, event) {
if(!this._canMove) {
// 禁止移动
return
}
let delta = touch.getDelta();
this.node.x += delta.x / this._scale;
this.node.y += delta.y / this._scale;
......@@ -102,12 +107,12 @@ cc.Class({
console.log("enter right");
cc.game.emit("STOP_ALL_AUDIO");
this.playSound(0);
this._soundOp.node.getComponent("op_sound").correct(this._spriteFrame, this._width, this._height);
this.node.destroy();
} else {
console.log("enter false");
cc.game.emit("STOP_ALL_AUDIO");
cc.game.emit("MOVE_CONTROL", false); // 广播事件 全集禁止拖动
this.playSound(1);
this.node.active = false;
this._soundOp.node.getComponent("op_sound").wrong(this._spriteFrame, this._width, this._height);
......@@ -122,6 +127,11 @@ cc.Class({
}
},
// 移动控制
moveControl(status) {
this._canMove = status?true:false;
},
/**
* 当碰撞产生的时候调用
* @param {Collider} other 产生碰撞的另一个碰撞组件
......
......@@ -113,6 +113,7 @@ cc.Class({
this.rightPic.spriteFrame = null;
this._opPic.node.active = true;
this._opPic.node.getComponent("op_pic").resetPos();
cc.game.emit("MOVE_CONTROL", true); // 广播事件 开启拖动
}, 1.2);
},
......
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