Commit 93babd5f authored by Tt's avatar Tt

增加word生成

parent 072d94db
...@@ -93,7 +93,7 @@ ...@@ -93,7 +93,7 @@
"__id__": 39 "__id__": 39
}, },
{ {
"__id__": 52 "__id__": 53
} }
], ],
"_active": true, "_active": true,
...@@ -1022,7 +1022,7 @@ ...@@ -1022,7 +1022,7 @@
"__uuid__": "8da4b052-dc5f-4ec5-880f-0487104c524b" "__uuid__": "8da4b052-dc5f-4ec5-880f-0487104c524b"
}, },
"_type": 0, "_type": 0,
"_sizeMode": 1, "_sizeMode": 0,
"_fillType": 0, "_fillType": 0,
"_fillCenter": { "_fillCenter": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
...@@ -1411,8 +1411,8 @@ ...@@ -1411,8 +1411,8 @@
"__type__": "TypedArray", "__type__": "TypedArray",
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
-872.208, -676.319,
295.276, 1274.723,
0, 0,
0, 0,
0, 0,
...@@ -1929,7 +1929,11 @@ ...@@ -1929,7 +1929,11 @@
} }
], ],
"_active": true, "_active": true,
"_components": [], "_components": [
{
"__id__": 52
}
],
"_prefab": null, "_prefab": null,
"_opacity": 255, "_opacity": 255,
"_color": { "_color": {
...@@ -1941,8 +1945,8 @@ ...@@ -1941,8 +1945,8 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 0, "width": 110,
"height": 0 "height": 110
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
...@@ -1953,8 +1957,8 @@ ...@@ -1953,8 +1957,8 @@
"__type__": "TypedArray", "__type__": "TypedArray",
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
275.544, -410.844,
-109.563, 1311.419,
0, 0,
0, 0,
0, 0,
...@@ -1980,7 +1984,7 @@ ...@@ -1980,7 +1984,7 @@
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "img_keyboard_b", "_name": "img_keyboard_1",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 39 "__id__": 39
...@@ -2074,7 +2078,7 @@ ...@@ -2074,7 +2078,7 @@
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "img_keyboard_o", "_name": "img_keyboard_2",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 39 "__id__": 39
...@@ -2168,7 +2172,7 @@ ...@@ -2168,7 +2172,7 @@
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "img_keyboard_p", "_name": "img_keyboard_3",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 39 "__id__": 39
...@@ -2262,7 +2266,7 @@ ...@@ -2262,7 +2266,7 @@
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "img_keyboard_g", "_name": "img_keyboard_4",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 39 "__id__": 39
...@@ -2356,7 +2360,7 @@ ...@@ -2356,7 +2360,7 @@
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "img_keyboard_y", "_name": "img_keyboard_5",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 39 "__id__": 39
...@@ -2545,6 +2549,76 @@ ...@@ -2545,6 +2549,76 @@
"_N$cacheMode": 0, "_N$cacheMode": 0,
"_id": "a9geZOjwhOzolP6BmUqQKt" "_id": "a9geZOjwhOzolP6BmUqQKt"
}, },
{
"__type__": "cc.Button",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 39
},
"_enabled": true,
"_normalMaterial": null,
"_grayMaterial": null,
"duration": 0.1,
"zoomScale": 1.2,
"clickEvents": [],
"_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": {
"__id__": 39
},
"_id": "a5CSFc15pHJrUqBqHzlHYf"
},
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "layout_words", "_name": "layout_words",
...@@ -2554,11 +2628,7 @@ ...@@ -2554,11 +2628,7 @@
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [],
{
"__id__": 53
}
],
"_prefab": null, "_prefab": null,
"_opacity": 255, "_opacity": 255,
"_color": { "_color": {
...@@ -2582,8 +2652,8 @@ ...@@ -2582,8 +2652,8 @@
"__type__": "TypedArray", "__type__": "TypedArray",
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
574.248, 0,
-269.848, 0,
0, 0,
0, 0,
0, 0,
...@@ -2607,33 +2677,6 @@ ...@@ -2607,33 +2677,6 @@
"groupIndex": 0, "groupIndex": 0,
"_id": "6bgUStIA5IBZsfN73tkScS" "_id": "6bgUStIA5IBZsfN73tkScS"
}, },
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 52
},
"_enabled": false,
"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": 0,
"_originalHeight": 0,
"_id": "a9lqlLNsFK9L1knW5VLscs"
},
{ {
"__type__": "cc.Canvas", "__type__": "cc.Canvas",
"_name": "", "_name": "",
......
...@@ -49,6 +49,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -49,6 +49,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
} }
private layout_blocks: cc.Node; private layout_blocks: cc.Node;
private layout_words: cc.Node;
initBlocks() { initBlocks() {
this.layout_blocks = pg.view.find(this, 'layout_blocks'); this.layout_blocks = pg.view.find(this, 'layout_blocks');
this.layout_blocks.removeAllChildren() this.layout_blocks.removeAllChildren()
...@@ -68,6 +69,138 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -68,6 +69,138 @@ export default class SceneComponent extends MyCocosSceneComponent {
} }
} }
gameStart() { gameStart() {
let word = pg.view.find(this, 'word');
this.layout_words = pg.view.find(this, 'layout_words');
this.layout_words.removeAllChildren()
let words = GameNGT14.getIns().getCurrent().getWords();
let space = { x: 150, y: 150 }
words.forEach((w, index) => {
let node = cc.instantiate(word);
let data = w;
if (index < 5) {
node.x = 280 + space.x * index
node.y = -110
} else if (index < 9) {
node.x = 355 + space.x * (index - 5)
node.y = -110 - space.y;
} else {
node.x = 280 + space.x * (index - 9)
node.y = -110 - space.y * 2;
}
this.layout_words.addChild(node);
this.updateWord(node, data);
});
}
updateWord(node, data) {
node.data = data;
pg.view.setString(pg.view.find(node, 'label'), data);
node.on(cc.Node.EventType.TOUCH_START, this.onItemTouchStart, this);
node.on(cc.Node.EventType.TOUCH_MOVE, this.onItemTouchMove, this);
node.on(cc.Node.EventType.TOUCH_END, this.onItemTouchEnd, this);
node.on(cc.Node.EventType.TOUCH_CANCEL, this.onItemTouchCancel, this);
}
private setTouchPos(e) {
let item = e.target;
let location = e.getLocation();
cc.Tween.stopAllByTarget(item);
let pos = location.sub(cc.v2(1920 / 2, 1080 / 2));
item.x = pos.x;
item.y = pos.y;
}
private touching: any;
onItemTouchStart(e) {
if (this.touching) return;
let target: cc.Node = e.target;
let data: string = target.data;
this.setTouchPos(e);
this.touching = data;
}
onItemTouchMove(e) {
let target: cc.Node = e.target;
let data = target.data;
if (!this.touching) return;
if (this.touching != data) return;
this.setTouchPos(e);
}
onItemTouchEnd(e) {
let target: cc.Node = e.target;
let data = target.data;
if (!this.touching) return;
if (this.touching != data) return;
// let rect = cc.rect(target.x, target.y, target.width, target.height);
let rect = cc.rect(target.x, target.y, 50, 50);
//坐标转换
console.log("1123123123")
return;
let boat_left = pg.view.find(this, 'layout_bottom/boat_left')
let boat_right = pg.view.find(this, 'layout_bottom/boat_right')
let leftRect = cc.rect(boat_left.x - boat_left.width / 2, boat_left.y - boat_left.height / 2, boat_left.width, boat_left.height);
let rightRect = cc.rect(boat_right.x - boat_right.width / 2, boat_right.y - boat_right.height / 2, boat_right.width, boat_right.height);
let isRight = false;
let currentRect = null;
// if (rect.intersects(leftRect)) {
// isRight = !!Game.getIns().boatLeft.isChild(data);
// Game.getIns().boatLeft.setRight(data);
// currentRect = leftRect;
// } else if (rect.intersects(rightRect)) {
// isRight = !!Game.getIns().boatRight.isChild(data);
// Game.getIns().boatRight.setRight(data);
// currentRect = rightRect;
// }
if (!currentRect) {
this.touching = null;
this.playLocalAudio('error').then(() => {
this.touching = null;
// this.updateItem(target, data);
})
return;
}
if (isRight) {
let item = target;
let lastArea = 100;
// this.playLocalAudio('right').then(() => {
// if (data.audioUrl) {
// pg.audio.playAudioByUrlThen(data.audioUrl).then(() => {
// this.touching = null;
// })
// } else {
// this.touching = null;
// }
// })
if (item.scaleX == -1) {
// 计算当前坐标距离最左侧的距离
let space = currentRect.width - ((rect.x + rect.width) - currentRect.x) - lastArea / 5;
let time = space / 10;
cc.tween(item).by(time, { x: space }).start();
} else {
// 计算当前坐标距离最左侧的距离
let space = rect.x - currentRect.x - lastArea;
let time = space / 10;
cc.tween(item).by(time, { x: -space }).start();
}
item.off(cc.Node.EventType.TOUCH_START, this.onItemTouchStart, this);
item.off(cc.Node.EventType.TOUCH_MOVE, this.onItemTouchMove, this);
item.off(cc.Node.EventType.TOUCH_END, this.onItemTouchEnd, this);
item.off(cc.Node.EventType.TOUCH_CANCEL, this.onItemTouchCancel, this);
pg.event.emit('mouse_05_add')
} else {
this.playLocalAudio('error').then(() => {
this.touching = null;
// this.updateItem(target, data);
})
}
//判断是否结束了
// if (Game.getIns().boatLeft.isAllRight() && Game.getIns().boatRight.isAllRight()) {
// this.showGameOver();
// }
}
onItemTouchCancel() {
} }
playLocalAudio(audioName) { playLocalAudio(audioName) {
......
...@@ -83,11 +83,27 @@ export class Question { ...@@ -83,11 +83,27 @@ export class Question {
public id: number; public id: number;
public list: Array<Option>; public list: Array<Option>;
public submit: BOARD_STATE; public submit: BOARD_STATE;
public words;
public answer;
constructor(data) { constructor(data) {
this.id = Question.id++; this.id = Question.id++;
console.log(data); console.log(data);
this.list = data.options.map(option => new Option(option)); this.list = data.options.map(option => new Option(option));
this.submit = BOARD_STATE.DEFAULT this.submit = BOARD_STATE.DEFAULT
this.answer = data.answer
this.words = data.answer.split('');
while (this.words.length < 14) {
let str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
this.words.push(str[Math.floor(Math.random() * str.length)])
}
for (let i = 0; i < 10; i++) {
this.words.sort((A, B) => {
return Math.random() < 0.5
})
}
}
getWords() {
return this.words.concat();
} }
setSubmit(state) { setSubmit(state) {
this.submit = state this.submit = state
......
...@@ -4588,7 +4588,7 @@ declare namespace cc { ...@@ -4588,7 +4588,7 @@ declare namespace cc {
/** !#en Returns a normalized vector representing the forward direction (Z axis) of the node in world space. /** !#en Returns a normalized vector representing the forward direction (Z axis) of the node in world space.
!#zh 获取节点正前方(z 轴)面对的方向,返回值为世界坐标系下的归一化向量 */ !#zh 获取节点正前方(z 轴)面对的方向,返回值为世界坐标系下的归一化向量 */
forward: Vec3; forward: Vec3;
data: { x: number; y: number; }; data: any;
/** /**
@param name name @param name name
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
"experimentalDecorators": true, "experimentalDecorators": true,
"skipLibCheck": true, "skipLibCheck": true,
"outDir": "temp/vscode-dist", "outDir": "temp/vscode-dist",
"allowJs": true,
"forceConsistentCasingInFileNames": true "forceConsistentCasingInFileNames": true
}, },
"exclude": [ "exclude": [
......
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