Commit fb89326c authored by linzhiguo's avatar linzhiguo

# bugs

parent ebe4b858
This diff is collapsed.
...@@ -198,7 +198,11 @@ cc.Class({ ...@@ -198,7 +198,11 @@ cc.Class({
this._kind_group = cc.find('Canvas/fg/kind').getComponent(cc.js.getClassByName('KindGroup')); this._kind_group = cc.find('Canvas/fg/kind').getComponent(cc.js.getClassByName('KindGroup'));
this._move_area.height = this._frameSize.height - 260; this._move_area.height = this._frameSize.height - 260;
this._ys = [-this._move_area.height/4, this._move_area.height/4]; let h1 = this._frameSize.height - 260 - 216*2;
let s1 = h1/3;
let offy = 216/2 +10;
this._ys = [-offy, offy];
// let option_node = cc.find('res/option'); // let option_node = cc.find('res/option');
// let option = option_node.getComponent(cc.js.getClassByName('WordOption')); // let option = option_node.getComponent(cc.js.getClassByName('WordOption'));
...@@ -214,7 +218,10 @@ cc.Class({ ...@@ -214,7 +218,10 @@ cc.Class({
}); });
cc.find('Canvas/show').on('click', ()=>{ cc.find('Canvas/show').on('click', ()=>{
let item = cc.instantiate(this._kind_group.template_node);
this._kind_group.node.addChild(item);
item.y = 43;
this._kind_group.updateView();
}); });
...@@ -234,7 +241,13 @@ cc.Class({ ...@@ -234,7 +241,13 @@ cc.Class({
let option = option_node.getComponent(cc.js.getClassByName('WordOption')); let option = option_node.getComponent(cc.js.getClassByName('WordOption'));
if (this._touched != true && cc.rect(option_node.getBoundingBoxToWorld()).contains(event.touch._point)){ if (this._touched != true && cc.rect(option_node.getBoundingBoxToWorld()).contains(event.touch._point)){
this.playAudioByName('tap'); this.playAudioByName('tap');
this._moved = false; cc.tween(this)
.delay(0.5)
.call(()=>{
option.playAudio();
})
.start();
//this._moved = false;
this._touched = true; this._touched = true;
selected.copyValues(option); selected.copyValues(option);
selected.selected(true); selected.selected(true);
...@@ -263,7 +276,7 @@ cc.Class({ ...@@ -263,7 +276,7 @@ cc.Class({
this.node.on(cc.Node.EventType.TOUCH_CANCEL, (event)=>{ this.node.on(cc.Node.EventType.TOUCH_CANCEL, (event)=>{
if (!this._touched) if (!this._touched)
return; return;
this._moved = true; //this._moved = true;
this._touched = false; this._touched = false;
selected.target.active = true; selected.target.active = true;
selected.node.x = selected.cx; selected.node.x = selected.cx;
...@@ -295,6 +308,13 @@ cc.Class({ ...@@ -295,6 +308,13 @@ cc.Class({
if (this.tryFinish()) if (this.tryFinish())
this.pageFinish(); this.pageFinish();
}); });
cc.tween(this)
.delay(0.5)
.call(()=>{
ot.playAudio();
})
.start();
selected.target.removeFromParent(); selected.target.removeFromParent();
selected.target = null; selected.target = null;
...@@ -321,7 +341,6 @@ cc.Class({ ...@@ -321,7 +341,6 @@ cc.Class({
this.updateData(); this.updateData();
this.upForeground(()=>{ this.upForeground(()=>{
this._moved = true; this._moved = true;
this.playAudioByName('up');
}); });
}); });
this._btn_start.active = true; this._btn_start.active = true;
...@@ -335,6 +354,11 @@ cc.Class({ ...@@ -335,6 +354,11 @@ cc.Class({
// this.resetData(); // this.resetData();
// }); // });
this.resetData(); this.resetData();
this._btn_start.active = false;
this.updateData();
this.upForeground(()=>{
this._moved = true;
});
}); });
}, },
...@@ -343,9 +367,11 @@ cc.Class({ ...@@ -343,9 +367,11 @@ cc.Class({
let fg_top = cc.find('Canvas/fg_top').y; let fg_top = cc.find('Canvas/fg_top').y;
let fg_bottom = fg_top - 260; let fg_bottom = fg_top - 260;
fg.y = fg_bottom; fg.y = fg_bottom;
this.playAudioByName('up');
cc.tween(fg) cc.tween(fg)
.to(0.3, {y :fg_top}) .to(0.3, {y :fg_top})
.call(()=>{ .call(()=>{
this._moved = true;
cb && cb(); cb && cb();
}) })
.start(); .start();
...@@ -584,17 +610,15 @@ cc.Class({ ...@@ -584,17 +610,15 @@ cc.Class({
onode.addChild(item); onode.addChild(item);
op = item.getComponent(cc.js.getClassByName('WordOption')); op = item.getComponent(cc.js.getClassByName('WordOption'));
op.init(os[i]); op.init(os[i]);
console.log(item._w);
this._xs[i%2] -= (i < 2 ? item._w/2 : item._w); this._xs[i%2] -= (i < 2 ? item._w/2 : item._w);
item.x = this._xs[i%2]; item.x = this._xs[i%2];
console.log(item.x);
item.y = this._ys[i%2]; item.y = this._ys[i%2];
} }
}, },
pageFinish(){ pageFinish(){
this._moved = false;
this._page_idx ++; this._page_idx ++;
this.downForeground(()=>{ this.downForeground(()=>{
if (this._page_idx >= this._page_max){ if (this._page_idx >= this._page_max){
...@@ -610,14 +634,12 @@ cc.Class({ ...@@ -610,14 +634,12 @@ cc.Class({
this._page_idx = 0; this._page_idx = 0;
this.upForeground(()=>{ this.upForeground(()=>{
this.updateData(); this.updateData();
this.playAudioByName('up');
}); });
}); });
} }
else{ else{
this.upForeground(()=>{ this.upForeground(()=>{
this.updateData(); this.updateData();
this.playAudioByName('up');
}); });
} }
}); });
...@@ -659,7 +681,8 @@ cc.Class({ ...@@ -659,7 +681,8 @@ cc.Class({
if (item.x > this._frameSize.width + item._w*1.2){ if (item.x > this._frameSize.width + item._w*1.2){
this._xs[i%2] -= item._w*1.2; this._xs[i%2] -= item._w*1.2;
item.x = Math.min(-item._w/2, this._xs[i%2]); //item.x = Math.min(-item._w/2, this._xs[i%2]);
item.x = -item._w/2;
} }
} }
}, },
......
...@@ -23,7 +23,6 @@ cc.Class({ ...@@ -23,7 +23,6 @@ cc.Class({
this.node.addChild(item); this.node.addChild(item);
kind = item.getComponent(cc.js.getClassByName('WordKind')); kind = item.getComponent(cc.js.getClassByName('WordKind'));
kind.init(data[i]); kind.init(data[i]);
console.log(i);
item.y += 43; item.y += 43;
} }
...@@ -35,6 +34,7 @@ cc.Class({ ...@@ -35,6 +34,7 @@ cc.Class({
let wr = sw/1280; let wr = sw/1280;
let num = this.node.childrenCount; let num = this.node.childrenCount;
let width = -1; let width = -1;
let w_scale = 1;
if (num== 2){ if (num== 2){
this.layout.paddingLeft = 100; this.layout.paddingLeft = 100;
this.layout.spacingX = 100; this.layout.spacingX = 100;
...@@ -54,7 +54,7 @@ cc.Class({ ...@@ -54,7 +54,7 @@ cc.Class({
this.layout.paddingLeft = 10; this.layout.paddingLeft = 10;
this.layout.spacingX = 10; this.layout.spacingX = 10;
width = (1280-num*10-10) / num; width = (1280-num*10-10) / num;
w_scale = width/273;
} }
this.layout.paddingLeft *= wr; this.layout.paddingLeft *= wr;
...@@ -67,6 +67,7 @@ cc.Class({ ...@@ -67,6 +67,7 @@ cc.Class({
for(let i = 0; i < num; i++){ for(let i = 0; i < num; i++){
this.node.children[i].width = width; this.node.children[i].width = width;
this.node.children[i].getComponent(cc.js.getClassByName('WordKind')).updateScale(w_scale);
} }
} }
......
...@@ -120,6 +120,7 @@ cc.Class({ ...@@ -120,6 +120,7 @@ cc.Class({
node.scale *= sr; node.scale *= sr;
// node.opacity = 0; // node.opacity = 0;
option.adjustPicSize(); option.adjustPicSize();
cb && cb();
// cc.tween(node) // cc.tween(node)
// .to(0.5, {opacity:255}) // .to(0.5, {opacity:255})
// .call(()=>{ // .call(()=>{
...@@ -131,6 +132,22 @@ cc.Class({ ...@@ -131,6 +132,22 @@ cc.Class({
this.show_node.active = false; this.show_node.active = false;
this.animate_node.active = false; this.animate_node.active = false;
}); });
},
updateScale(scale){
if (scale == 1) return;
this.tips_text_bg.scale = scale;
this.tips_text_bg.getComponent(cc.Widget).isAlignHorizontalCenter = true;
this.tips_pic_bg.scale = scale;
this.tips_pic_bg.getComponent(cc.Widget).isAlignHorizontalCenter = true;
let item, len = this.layout.childrenCount;
for(i = 0; i < len; i++){
item = this.layout.children[i];
item.width *= scale;
item.height *= scale;
item.scale *= scale;
}
} }
......
import { getSpriteFrimeByUrl,setSpriteWH } from "../script/util"; import { getSpriteFrimeByUrl,setSpriteWH, RandomInt,playAudioByUrl} from "../script/util";
cc.Class({ cc.Class({
extends: cc.Component, extends: cc.Component,
...@@ -56,6 +56,7 @@ cc.Class({ ...@@ -56,6 +56,7 @@ cc.Class({
this.word_finish.active = false; this.word_finish.active = false;
this.node._w = [340, 410][type]; this.node._w = [340, 410][type];
this.resetWH(); this.resetWH();
this.changeBackground();
}, },
resetWH(){ resetWH(){
...@@ -101,12 +102,18 @@ cc.Class({ ...@@ -101,12 +102,18 @@ cc.Class({
this.setPic(o.pic.spriteFrame); this.setPic(o.pic.spriteFrame);
this.pic.width = o.pic.node.width; this.pic.width = o.pic.node.width;
this.pic.height = o.pic.node.height; this.pic.height = o.pic.node.height;
this.pic_node.getComponent(cc.Sprite).spriteFrame = o.pic_node.getComponent(cc.Sprite).spriteFrame;
this.pic_finish.getComponent(cc.Sprite).spriteFrame = o.pic_finish.getComponent(cc.Sprite).spriteFrame;
} }
else if (this._type == 1) else if (this._type == 1){
this.setWord(o.word.string); this.setWord(o.word.string);
this.word_node.getComponent(cc.Sprite).spriteFrame = o.word_node.getComponent(cc.Sprite).spriteFrame;
this.word_finish.getComponent(cc.Sprite).spriteFrame = o.word_finish.getComponent(cc.Sprite).spriteFrame;
}
this.kind_id = o.kind_id; this.kind_id = o.kind_id;
this.node._w = o.node._w; this.node._w = o.node._w;
this.audio = o.audio;
}, },
adjustPicSize(){ adjustPicSize(){
...@@ -123,11 +130,36 @@ cc.Class({ ...@@ -123,11 +130,36 @@ cc.Class({
this.word_node.getComponent(cc.Sprite).enabled = false; this.word_node.getComponent(cc.Sprite).enabled = false;
if (this._type == 0){ if (this._type == 0){
this.pic_finish.active = true; this.pic_finish.active = true;
this.node.width = this.pic_finish.width;
this.node.height = this.pic_finish.height;
} }
else{ else{
this.word_finish.active = true; this.word_finish.active = true;
this.node.width = this.word_finish.width;
this.node.height = this.word_finish.height;
} }
} },
changeBackground(){
let type = this._type;
let fname;
if (type == 0){
fname = 'bg_picture' + (RandomInt(2)+1);
this.pic_node.getComponent(cc.Sprite).spriteFrame = cc.find('res/option_bg/'+fname).getComponent(cc.Sprite).spriteFrame;
fname += '-finish';
this.pic_finish.getComponent(cc.Sprite).spriteFrame = cc.find('res/option_bg/'+fname).getComponent(cc.Sprite).spriteFrame;
}
else if (type == 1){
fname = 'bg_word' + (RandomInt(2)+1);
this.word_node.getComponent(cc.Sprite).spriteFrame = cc.find('res/option_bg/'+fname).getComponent(cc.Sprite).spriteFrame;
fname += '-finish';
this.word_finish.getComponent(cc.Sprite).spriteFrame = cc.find('res/option_bg/'+fname).getComponent(cc.Sprite).spriteFrame;
}
},
playAudio(){
if (this.audio && this.audio!=""){
playAudioByUrl(this.audio);
}
},
}); });
\ 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