Commit 9bfc7f14 authored by wangxin's avatar wangxin

beta 1.0

parent 848e7a8e
......@@ -129,7 +129,7 @@ cc.Class({
getDefaultData() {
const dataJson =
'{"title":"hello","audio_title":"http://staging-teach.cdn.ireadabc.com/f7fb9f71ab7d460ac2f78c85efba7610.mp3","options":[{"pic_url":"http://staging-teach.cdn.ireadabc.com/ae96e15404c873878ed4f4ce03f9f495.jpeg","audio_url":"http://staging-teach.cdn.ireadabc.com/0f0482ddb8c0d3329165ab0612683148.mp3"},{"pic_url":"http://staging-teach.cdn.ireadabc.com/d16a95047e369fbc7f94428624859d03.jpeg","audio_url":"http://staging-teach.cdn.ireadabc.com/784cd4188bf126d6c3c9395d9a807619.mp3"},{"pic_url":"http://staging-teach.cdn.ireadabc.com/5433aa00faced2d5e02f9cecce63ba09.jpeg","audio_url":"http://staging-teach.cdn.ireadabc.com/0f0482ddb8c0d3329165ab0612683148.mp3"},{"pic_url":"http://staging-teach.cdn.ireadabc.com/9298013cc63aa40035dbd18f1f8380a8.jpeg","audio_url":"http://staging-teach.cdn.ireadabc.com/784cd4188bf126d6c3c9395d9a807619.mp3"}]}';
'{"title":"hello","audio_title":"http://staging-teach.cdn.ireadabc.com/f7fb9f71ab7d460ac2f78c85efba7610.mp3","options":[{"pic_url":"http://staging-teach.cdn.ireadabc.com/004be996ea209e366951a7c4b6a3e55f.jpeg","audio_url":"http://staging-teach.cdn.ireadabc.com/0f0482ddb8c0d3329165ab0612683148.mp3"},{"pic_url":"http://staging-teach.cdn.ireadabc.com/785b0bc1766658373e4ebdcbd694a088.jpeg","audio_url":"http://staging-teach.cdn.ireadabc.com/784cd4188bf126d6c3c9395d9a807619.mp3"},{"pic_url":"http://staging-teach.cdn.ireadabc.com/5433aa00faced2d5e02f9cecce63ba09.jpeg","audio_url":"http://staging-teach.cdn.ireadabc.com/0f0482ddb8c0d3329165ab0612683148.mp3"},{"pic_url":"http://staging-teach.cdn.ireadabc.com/9298013cc63aa40035dbd18f1f8380a8.jpeg","audio_url":"http://staging-teach.cdn.ireadabc.com/784cd4188bf126d6c3c9395d9a807619.mp3"}]}';
const data = JSON.parse(dataJson);
return data;
},
......
......@@ -31,6 +31,8 @@ cc.Class({
_soundOp: null, // 碰到的选框
_picUrl: null, // 图片地址
_spriteFrame: null,
_width: null,
_height: null,
},
onEnable() {
......@@ -54,9 +56,28 @@ cc.Class({
setPic() {
cc.loader.load({ url: this._picUrl }, (err, img) => {
const spriteFrame = new cc.SpriteFrame(img);
this.pic.spriteFrame = spriteFrame;
this._spriteFrame = spriteFrame;
let frame = new cc.SpriteFrame(img);
let frameSize = frame.getOriginalSize();
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;
scale = 1;
if (frameSize.width > 168) {
scale = 168 / frameSize.width;
}
this.pic.node.width = frameSize.width * scale;
this.pic.node.height = frameSize.height * scale;
this._width = this.pic.node.width;
this._height = this.pic.node.height;
});
},
......@@ -80,13 +101,13 @@ cc.Class({
console.log("enter right");
this.playSound(0);
this._soundOp.node.getComponent("op_sound").correct(this._spriteFrame);
this._soundOp.node.getComponent("op_sound").correct(this._spriteFrame, this._width, this._height);
this.node.destroy();
} else {
console.log("enter false");
this.playSound(1);
this.node.active = false;
this._soundOp.node.getComponent("op_sound").wrong(this._spriteFrame);
this._soundOp.node.getComponent("op_sound").wrong(this._spriteFrame, this._width, this._height);
}
} else {
this.node.setPosition(this._ori_pos);
......
......@@ -69,12 +69,10 @@ cc.Class({
console.log("on collision exit");
},
correct(spriteFrame) {
correct(spriteFrame, width, height) {
this.rightFrame.active = true;
// cc.loader.load({ url }, (err, img) => {
// const spriteFrame = new cc.SpriteFrame(img);
// this.rightPic.spriteFrame = spriteFrame;
// });
this.rightPic.node.width = width;
this.rightPic.node.height = height;
this.rightPic.spriteFrame = spriteFrame;
var par = cc.instantiate(this.particle_star);
......@@ -85,13 +83,12 @@ cc.Class({
cc.game.emit("RIGHT");
},
wrong(spriteFrame) {
wrong(spriteFrame, width, height) {
this.rightFrame.active = true;
// cc.loader.load({ url }, (err, img) => {
// const spriteFrame = new cc.SpriteFrame(img);
// this.rightPic.spriteFrame = spriteFrame;
// });
this.rightPic.node.width = width;
this.rightPic.node.height = height;
this.rightPic.spriteFrame = spriteFrame;
let time = 0.1;
let action = cc.repeat(
cc.sequence(cc.moveBy(time, -10, 0), cc.moveBy(time, 10, 0), cc.moveBy(time, 10, 0), cc.moveBy(time, -10, 0)),
......
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