Commit 453dbde7 authored by wangxin's avatar wangxin

碰撞

parent b1ab6400
{
"ver": "2.0.1",
"uuid": "f7ba93b1-0719-40f3-8482-0d5d94a2fb8f",
"downloadMode": 0,
"duration": 3.787755,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "684d7cb6-2589-4ca9-97e4-4fee3d611cdc",
"downloadMode": 0,
"duration": 1.854694,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "5060d073-9761-4a5c-8910-5439b56725bf",
"downloadMode": 0,
"duration": 2.324917,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "c271a59a-d4e5-453e-8e2e-5b97fa3e4b43",
"downloadMode": 0,
"duration": 0.556563,
"subMetas": {}
}
\ No newline at end of file
...@@ -1426,6 +1426,20 @@ ...@@ -1426,6 +1426,20 @@
"op_pic": { "op_pic": {
"__uuid__": "b74714cb-b4ed-49a6-9955-c21a7c47db01" "__uuid__": "b74714cb-b4ed-49a6-9955-c21a7c47db01"
}, },
"sounds": [
{
"__uuid__": "684d7cb6-2589-4ca9-97e4-4fee3d611cdc"
},
{
"__uuid__": "5060d073-9761-4a5c-8910-5439b56725bf"
},
{
"__uuid__": "c271a59a-d4e5-453e-8e2e-5b97fa3e4b43"
},
{
"__uuid__": "f7ba93b1-0719-40f3-8482-0d5d94a2fb8f"
}
],
"_id": "e687yyoRBIzZAOVRL8Sseh" "_id": "e687yyoRBIzZAOVRL8Sseh"
} }
] ]
\ No newline at end of file
...@@ -35,6 +35,12 @@ cc.Class({ ...@@ -35,6 +35,12 @@ cc.Class({
default: null, default: null,
type: cc.Prefab, type: cc.Prefab,
}, },
// 声音,0-进入,1-正确,2-错误,3-结束
sounds: {
default: [],
type: [cc.AudioClip],
},
}, },
// 生命周期 onLoad // 生命周期 onLoad
...@@ -191,9 +197,11 @@ cc.Class({ ...@@ -191,9 +197,11 @@ cc.Class({
} }
var self = this; var self = this;
schduleOnce(function () { this.node.scheduleOnce(function () {
self.pic_container.getComponent(cc.Layout).enabled = false; self.pic_container.getComponent(cc.Layout).enabled = false;
}, 0.5); }, 0.5);
this.playSound(0);
}, },
initBg() { initBg() {
...@@ -283,5 +291,10 @@ cc.Class({ ...@@ -283,5 +291,10 @@ cc.Class({
} }
}, },
// 播放声音
playSound(index) {
cc.audioEngine.playEffect(this.sounds[index], false);
},
// ------------------------------------------ // ------------------------------------------
}); });
...@@ -14,7 +14,9 @@ cc.Class({ ...@@ -14,7 +14,9 @@ cc.Class({
_opId: 0, // 选项id _opId: 0, // 选项id
_ori_pos: null, // 初始位置 _ori_pos: null, // 初始位置
_isEnter: false, // 是否碰到上面的选项框 _isEnter: false, // 是否碰到对的选框
_isContact: false, // 是否碰到了选项框
_soundOp: null, // 碰到的选框
}, },
onLoad() { onLoad() {
...@@ -69,10 +71,14 @@ cc.Class({ ...@@ -69,10 +71,14 @@ cc.Class({
}, },
onTouchEnd() { onTouchEnd() {
this.nodePos = this.node.getPosition(); //获取触摸结束之后的node坐标; this.nodePos = this.node.getPosition(); //获取触摸结束之后的node坐标;
if (this._isEnter) { if (this._isContact) {
console.log("enter right"); this.node.setPosition();
if (this._isEnter) {
console.log("enter right");
} else {
console.log("enter false");
}
} else { } else {
console.log("enter right");
this.node.setPosition(this._ori_pos); this.node.setPosition(this._ori_pos);
} }
}, },
...@@ -84,6 +90,8 @@ cc.Class({ ...@@ -84,6 +90,8 @@ cc.Class({
*/ */
onCollisionEnter: function (other, self) { onCollisionEnter: function (other, self) {
console.log("on collision"); console.log("on collision");
this._soundOp = other;
this._isContact = true;
if (other.getComponent("op_sound")._opId == this._opId) { if (other.getComponent("op_sound")._opId == this._opId) {
this._isEnter = true; this._isEnter = true;
} }
...@@ -97,9 +105,7 @@ cc.Class({ ...@@ -97,9 +105,7 @@ cc.Class({
onCollisionExit: function (other, self) { onCollisionExit: function (other, self) {
console.log("on collision exit"); console.log("on collision exit");
this._isEnter = false; this._isEnter = false;
}, this._isContact = false;
this._soundOp = null;
resetPos() {
// cc.tween(this.node).to()
}, },
}); });
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