Commit 1fab9d5d authored by 李维's avatar 李维

添加游戏页排序题

parent 307fca3e
{
"ver": "1.1.2",
"uuid": "c7844bce-f7f3-4440-950c-3b060af41edd",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.2.9",
"uuid": "e2d8086f-75f8-4d44-a894-88c1e26bb42c",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
// Learn cc.Class:
// - https://docs.cocos.com/creator/manual/en/scripting/class.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
cc.Class({
extends: cc.Component,
properties: {
// foo: {
// // ATTRIBUTES:
// default: null, // The default value will be used only when the component attaching
// // to a node for the first time
// type: cc.SpriteFrame, // optional, default is typeof default
// serializable: true, // optional, default is true
// },
// bar: {
// get () {
// return this._bar;
// },
// set (value) {
// this._bar = value;
// }
// },
},
// LIFE-CYCLE CALLBACKS:
// onLoad () {},
currentInputIndex: 0,
start () {
this.initEventListener();
},
initEventListener() {
const returnBtn = cc.find("buttons/return", this.node);
returnBtn.on("click", ()=>{
this.node.emit("onCancel");
this.hide();
})
const okBtn = cc.find("buttons/ok", this.node);
okBtn.on("click", ()=>{
const selectedContainer = cc.find("mainContainer/selected", this.node);
const allData = [];
selectedContainer.children.forEach(child=>{
allData.push(child.myData)
})
this.node.emit("onEnter", allData);
this.hide();
})
this.node.on("show", options => {
this.show(options);
})
},
show(options) {
this.node.opacity = 0;
this.node.x = 0;
this.node.y = 0;
this.node.active = true;
const template = cc.find("mainContainer/options/word", this.node);
const optionsContainer = cc.find("mainContainer/options", this.node);
const selectedContainer = cc.find("mainContainer/selected", this.node);
options.forEach(item => {
const newWord = cc.instantiate(template);
newWord.getComponent(cc.Label).string = item.word;
newWord.active = true;
newWord.myData = {
selected: false,
currentIndex: -1,
option: item,
};
optionsContainer.addChild(newWord);
newWord.on("click", ()=>{
if(newWord.selected) {
selectedContainer.removeChild(newWord)
optionsContainer.addChild(newWord)
newWord.myData.selected = false;
ewWord.myData.currentIndex = -1;
} else {
optionsContainer.removeChild(newWord)
selectedContainer.addChild(newWord)
newWord.myData.selected = true;
newWord.myData.currentIndex = this.currentInputIndex++;
}
})
});
cc.tween(this.node).to(0.1, {opacity: 255}).call(()=>{
}).start();
},
hide() {
this.node.opacity = 255;
cc.tween(this.node).to(0.1, {opacity: 0}).call(()=>{
this.node.x = 5000;
this.node.active = false;
}).start();
}
// update (dt) {},
});
{
"ver": "1.0.8",
"uuid": "8990719f-ca53-4c90-ba7b-eeecc7b16a85",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "45b9b2fc-e28e-4620-a813-94820f1317cb",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "1b41aab3-f2ca-48cb-a597-17bce5707713",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 120,
"height": 120,
"platformSettings": {},
"subMetas": {
"icon_input_ok": {
"ver": "1.0.4",
"uuid": "c3616ea2-7570-41eb-9505-2b0478de27d4",
"rawTextureUuid": "1b41aab3-f2ca-48cb-a597-17bce5707713",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0.5,
"offsetY": -0.5,
"trimX": 3,
"trimY": 3,
"width": 115,
"height": 115,
"rawWidth": 120,
"rawHeight": 120,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "91d71f77-d7a4-4a2d-8acf-335b27c7c50d",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 120,
"height": 120,
"platformSettings": {},
"subMetas": {
"icon_input_return": {
"ver": "1.0.4",
"uuid": "d9f5a0ac-32d2-4656-9f94-7d6d8cd0ab0e",
"rawTextureUuid": "91d71f77-d7a4-4a2d-8acf-335b27c7c50d",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": -0.5,
"trimX": 3,
"trimY": 3,
"width": 114,
"height": 115,
"rawWidth": 120,
"rawHeight": 120,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "50fccd09-97c0-44fa-8139-44e924feda54",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 3840,
"height": 2160,
"platformSettings": {},
"subMetas": {
"mask_bg": {
"ver": "1.0.4",
"uuid": "cda8c593-abed-4137-af06-fe4e79a2fdf6",
"rawTextureUuid": "50fccd09-97c0-44fa-8139-44e924feda54",
"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
This diff is collapsed.
...@@ -31,6 +31,9 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -31,6 +31,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
@property({type: cc.Node, displayName: "键盘"}) @property({type: cc.Node, displayName: "键盘"})
keyboard: cc.Node = null; keyboard: cc.Node = null;
@property({type: cc.Node, displayName: "文字排序"})
sortWords: cc.Node = null;
@property({type: cc.Node, displayName: "选择窗"}) @property({type: cc.Node, displayName: "选择窗"})
selectModal: cc.Node = null; selectModal: cc.Node = null;
...@@ -61,6 +64,12 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -61,6 +64,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.initScorePanel(); this.initScorePanel();
this.initActionButton(); this.initActionButton();
this.initScoreShow(); this.initScoreShow();
setTimeout(() => {
this.sortWords.emit("show", [
{word: "Fine"}, {word: "thank"}, {word: "you"}
])
}, 1000);
} }
// 初始化屏幕储存 // 初始化屏幕储存
...@@ -98,6 +107,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -98,6 +107,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
currentInputTarget = null; currentInputTarget = null;
onSelectedCallback = null; onSelectedCallback = null;
onKeyboardEnterCallback = null; onKeyboardEnterCallback = null;
onSortWordsEndCallback = null;
initEventListener() { initEventListener() {
// 注册键盘输入确定时间 // 注册键盘输入确定时间
this.keyboard.on("onEnter", (text)=>{ this.keyboard.on("onEnter", (text)=>{
...@@ -120,6 +130,20 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -120,6 +130,20 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.currentInputTarget = null; this.currentInputTarget = null;
} }
}) })
this.sortWords.on("onEnter", (e)=>{
this.onSortWordsEndCallback && this.onSortWordsEndCallback(this.currentInputTarget, e)
if(this.currentInputTarget) {
this.currentInputTarget = null;
}
})
this.sortWords.on("onCancel", (e)=>{
this.onSortWordsEndCallback && this.onSortWordsEndCallback(this.currentInputTarget, e)
if(this.currentInputTarget) {
this.currentInputTarget = null;
}
})
} }
// 初始化头部和底部图片 // 初始化头部和底部图片
......
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