Commit fe60e12a authored by limingzhe's avatar limingzhe

fix: debug

parent 1908d8af
...@@ -979,6 +979,7 @@ cc.Class({ ...@@ -979,6 +979,7 @@ cc.Class({
initData() { initData() {
console.log(' in initData'); console.log(' in initData');
this.poolData = {}
this.canTouch = true; this.canTouch = true;
const rows = []; const rows = [];
...@@ -1462,33 +1463,45 @@ cc.Class({ ...@@ -1462,33 +1463,45 @@ cc.Class({
getOneLetterItem(isAnim=false) { getOneLetterItem(isAnim=false) {
// const id = this.getRandomDataFromArray([1,2,3,4,5,6,7,8,9,10]); // const id = this.getRandomDataFromArray([1,2,3,4,5,6,7,8,9,10]);
const id = this.getRandomDataFromArray(this.colorIdArr);
const id = this.getRandomDataFromArray(this.colorIdArr);
const letter = this.itemLetterObj[id]; const letter = this.itemLetterObj[id];
const resName = 'item_' + id;
const item = getSprNode(resName);
this.itemBg.addChild(item);
const rtNode = this.getRichText(letter, 100, "#ffffff", 0, "#000000", false) let item = this.getPoolItem(id);
rtNode.y = 15; if (!item) {
const resName = 'item_' + id;
item = getSprNode(resName);
this.itemBg.addChild(item);
const rtNode = this.getRichText(letter, 100, "#ffffff", 0, "#000000", false)
rtNode.y = 15;
const rtNodeShadow = this.getRichText(letter, 100, "#ffffff", 4, "#000000", false) const rtNodeShadow = this.getRichText(letter, 100, "#ffffff", 4, "#000000", false)
rtNodeShadow.y = rtNode.y rtNodeShadow.y = rtNode.y
rtNodeShadow.opacity = 70; rtNodeShadow.opacity = 70;
rtNodeShadow.baseOpacity = 70; rtNodeShadow.baseOpacity = 70;
item.addChild(rtNodeShadow); item.addChild(rtNodeShadow);
item.addChild(rtNode); item.addChild(rtNode);
item.rtNode = rtNode; item.rtNode = rtNode;
item.rtNodeShadow = rtNodeShadow; item.rtNodeShadow = rtNodeShadow;
item.colorId = id;
item.on('touchstart', () => {
this.itemClick(item);
})
} else {
item.opacity = 255;
this.resetOneLetterItem(item, false)
}
item.letter = letter; item.letter = letter;
item.colorId = id;
item.on('touchstart', () => {
this.itemClick(item);
})
if (isAnim) { if (isAnim) {
...@@ -1527,6 +1540,11 @@ cc.Class({ ...@@ -1527,6 +1540,11 @@ cc.Class({
if (!this.canTouch) { if (!this.canTouch) {
return; return;
} }
if (item.opacity < 1) {
return
}
console.log('item.letter: ', item.letter); console.log('item.letter: ', item.letter);
this.canTouch = false; this.canTouch = false;
...@@ -1627,36 +1645,56 @@ cc.Class({ ...@@ -1627,36 +1645,56 @@ cc.Class({
} }
}, },
resetOneLetterItem(item) { resetOneLetterItem(item, isAnim=true) {
// const id = this.getRandomDataFromArray([1,2,3,4,5,6,7,8,9,10]); // const id = this.getRandomDataFromArray([1,2,3,4,5,6,7,8,9,10]);
const id = item.colorId; const id = item.colorId;
const letter = this.itemLetterObj[id]; const letter = this.itemLetterObj[id];
// const resName = 'item_' + id;
// const item = getSprNode(resName);
// this.itemBg.addChild(item);
this.delayCall(1 + Math.random() * 0.5, () => { // const resName = 'item_' + id;
const {rtNode, rtNodeShadow} = item; // const item = getSprNode(resName);
// this.itemBg.addChild(item);
cc.tween(rtNode) const {rtNode, rtNodeShadow} = item;
.to(0.5, {opacity: 0}, {easing:"cubicIn"}) item.letter = letter;
.call(() => {
this.refreshRichText(rtNode, letter);
})
.to(0.5, {opacity: 255}, {easing:"cubicOut"})
.start();
cc.tween(rtNodeShadow) if (!isAnim) {
.to(0.5, {opacity: 0}, {easing:"cubicIn"})
.call(() => { this.refreshRichText(rtNode, letter);
this.refreshRichText(rtNodeShadow, letter); this.refreshRichText(rtNodeShadow, letter);
})
.to(0.5, {opacity: rtNodeShadow.baseOpacity}, {easing:"cubicOut"}) return;
.start(); }
})
this.refreshRichText(rtNode, letter);
this.refreshRichText(rtNodeShadow, letter);
rtNodeShadow.opacity = 0;
cc.tween(rtNodeShadow)
.to(1, {opacity: rtNodeShadow.baseOpacity}, {easing:"cubicOut"})
.start();
// this.delayCall(1 + Math.random() * 0, () => {
// cc.tween(rtNode)
// .to(0.5, {opacity: 0}, {easing:"cubicIn"})
// .call(() => {
// this.refreshRichText(rtNode, letter);
// })
// .to(0.5, {opacity: 255}, {easing:"cubicOut"})
// .start();
// cc.tween(rtNodeShadow)
// .to(0.5, {opacity: 0}, {easing:"cubicIn"})
// .call(() => {
// this.refreshRichText(rtNodeShadow, letter);
// })
// .to(0.5, {opacity: rtNodeShadow.baseOpacity}, {easing:"cubicOut"})
// .start();
// })
item.letter = letter;
}, },
...@@ -1852,8 +1890,30 @@ cc.Class({ ...@@ -1852,8 +1890,30 @@ cc.Class({
this.addScore(item, score); this.addScore(item, score);
this.playSpineEffect(item, "light"); this.playSpineEffect(item, "light");
item.removeFromParent();
this.removeOneItem(item);
},
removeOneItem(item) {
item.opacity = 0;
item.x = -this.canvas.width;
this.addPoolItem(item, item.colorId);
},
addPoolItem(item, id) {
if (!this.poolData[id]) {
this.poolData[id] = [];
}
this.poolData[id].push(item);
},
getPoolItem(id) {
if (this.poolData[id] && this.poolData[id].length > 0) {
return this.poolData[id].pop();
}
}, },
addScore(item, score) { addScore(item, score) {
......
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