Commit decbabd3 authored by 唐鑫's avatar 唐鑫

游戏调整完成

parent ec2478ab
...@@ -33,13 +33,10 @@ ...@@ -33,13 +33,10 @@
"__id__": 20 "__id__": 20
}, },
{ {
"__id__": 23 "__id__": 24
},
{
"__id__": 26
}, },
{ {
"__id__": 29 "__id__": 28
}, },
{ {
"__id__": 32 "__id__": 32
...@@ -738,10 +735,13 @@ ...@@ -738,10 +735,13 @@
"_components": [ "_components": [
{ {
"__id__": 21 "__id__": 21
},
{
"__id__": 22
} }
], ],
"_prefab": { "_prefab": {
"__id__": 22 "__id__": 23
}, },
"_opacity": 255, "_opacity": 255,
"_color": { "_color": {
...@@ -765,8 +765,8 @@ ...@@ -765,8 +765,8 @@
"__type__": "TypedArray", "__type__": "TypedArray",
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
-29.336, -175.806,
73.964, 81.931,
0, 0,
0, 0,
0, 0,
...@@ -822,6 +822,33 @@ ...@@ -822,6 +822,33 @@
"_atlas": null, "_atlas": null,
"_id": "" "_id": ""
}, },
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 20
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 9,
"_left": -21.30600000000001,
"_right": 0,
"_top": -47.931,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_id": ""
},
{ {
"__type__": "cc.PrefabInfo", "__type__": "cc.PrefabInfo",
"root": { "root": {
...@@ -844,11 +871,14 @@ ...@@ -844,11 +871,14 @@
"_active": false, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 24 "__id__": 25
},
{
"__id__": 26
} }
], ],
"_prefab": { "_prefab": {
"__id__": 25 "__id__": 27
}, },
"_opacity": 255, "_opacity": 255,
"_color": { "_color": {
...@@ -872,8 +902,8 @@ ...@@ -872,8 +902,8 @@
"__type__": "TypedArray", "__type__": "TypedArray",
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
-29.648, -176.078,
74.275, 82.067,
0, 0,
0, 0,
0, 0,
...@@ -902,7 +932,7 @@ ...@@ -902,7 +932,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 23 "__id__": 24
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -930,110 +960,30 @@ ...@@ -930,110 +960,30 @@
"_id": "" "_id": ""
}, },
{ {
"__type__": "cc.PrefabInfo", "__type__": "cc.Widget",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "2ce7d58d-b6fe-4ef7-a128-de76f672a803"
},
"fileId": "bdj7Z5C1hG9ZUpslIq23db",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "bg_quan_huang",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": false,
"_components": [
{
"__id__": 27
}
],
"_prefab": {
"__id__": 28
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 130,
"height": 130
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
14.364,
-2.917,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Sprite",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 26 "__id__": 24
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "alignMode": 1,
{ "_target": null,
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" "_alignFlags": 9,
} "_left": -21.578000000000003,
], "_right": 0,
"_srcBlendFactor": 770, "_top": -48.06699999999999,
"_dstBlendFactor": 771, "_bottom": 0,
"_spriteFrame": { "_verticalCenter": 0,
"__uuid__": "4b7d087b-846b-42be-a0fd-0680a9428b88" "_horizontalCenter": 0,
}, "_isAbsLeft": true,
"_type": 0, "_isAbsRight": true,
"_sizeMode": 0, "_isAbsTop": true,
"_fillType": 0, "_isAbsBottom": true,
"_fillCenter": { "_isAbsHorizontalCenter": true,
"__type__": "cc.Vec2", "_isAbsVerticalCenter": true,
"x": 0, "_originalWidth": 0,
"y": 0 "_originalHeight": 0,
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "" "_id": ""
}, },
{ {
...@@ -1044,7 +994,7 @@ ...@@ -1044,7 +994,7 @@
"asset": { "asset": {
"__uuid__": "2ce7d58d-b6fe-4ef7-a128-de76f672a803" "__uuid__": "2ce7d58d-b6fe-4ef7-a128-de76f672a803"
}, },
"fileId": "f94BWi8LJI7LZb1nnh8wI/", "fileId": "bdj7Z5C1hG9ZUpslIq23db",
"sync": false "sync": false
}, },
{ {
...@@ -1057,6 +1007,9 @@ ...@@ -1057,6 +1007,9 @@
"_children": [], "_children": [],
"_active": false, "_active": false,
"_components": [ "_components": [
{
"__id__": 29
},
{ {
"__id__": 30 "__id__": 30
} }
...@@ -1074,8 +1027,8 @@ ...@@ -1074,8 +1027,8 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 130, "width": 397,
"height": 130 "height": 139
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
...@@ -1086,8 +1039,8 @@ ...@@ -1086,8 +1039,8 @@
"__type__": "TypedArray", "__type__": "TypedArray",
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
14.364, 0,
-3.482, 0,
0, 0,
0, 0,
0, 0,
...@@ -1116,7 +1069,7 @@ ...@@ -1116,7 +1069,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 29 "__id__": 28
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -1143,6 +1096,33 @@ ...@@ -1143,6 +1096,33 @@
"_atlas": null, "_atlas": null,
"_id": "" "_id": ""
}, },
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 28
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 45,
"_left": -23,
"_right": -23,
"_top": -23,
"_bottom": -23,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 170,
"_originalHeight": 100,
"_id": ""
},
{ {
"__type__": "cc.PrefabInfo", "__type__": "cc.PrefabInfo",
"root": { "root": {
...@@ -1618,7 +1598,7 @@ ...@@ -1618,7 +1598,7 @@
}, },
"_enabled": true, "_enabled": true,
"quan": { "quan": {
"__id__": 29 "__id__": 28
}, },
"tipsAnim": { "tipsAnim": {
"__id__": 4 "__id__": 4
...@@ -1639,7 +1619,13 @@ ...@@ -1639,7 +1619,13 @@
"__id__": 20 "__id__": 20
}, },
"icon_stop": { "icon_stop": {
"__id__": 23 "__id__": 24
},
"quan_lan": {
"__uuid__": "7651dd7c-f921-4f71-8006-4f25714d24b9"
},
"quan_huang": {
"__uuid__": "4b7d087b-846b-42be-a0fd-0680a9428b88"
}, },
"_id": "" "_id": ""
}, },
......
...@@ -12,6 +12,8 @@ cc.Class({ ...@@ -12,6 +12,8 @@ cc.Class({
btnX: cc.Node, btnX: cc.Node,
icon_play: cc.Node, icon_play: cc.Node,
icon_stop: cc.Node, icon_stop: cc.Node,
quan_lan: cc.SpriteFrame,
quan_huang: cc.SpriteFrame
}, },
data: null, data: null,
...@@ -21,7 +23,8 @@ cc.Class({ ...@@ -21,7 +23,8 @@ cc.Class({
this.quan.active = false this.quan.active = false
this.tipsAnim.node.active = false this.tipsAnim.node.active = false
this.handAnim.node.active = false this.handAnim.node.active = false
this.btnX.active = false // this.btnX.active = false
this.icon_stop.active = false
}, },
onEnable() { onEnable() {
...@@ -52,46 +55,67 @@ cc.Class({ ...@@ -52,46 +55,67 @@ cc.Class({
}, },
onTouchStart() { onTouchStart() {
if (this._playing) return return new Promise((resolve, reject) => {
if (this.audioId) return if (this._playing || this.audioId) {
if (this.data) { //增加暂停功能。
this.btnX.active = true this._playing = false;
if (this.data.pic_url && this.data.gIdx == 0) { //播放切换
tools.getSpriteFrimeByUrl(this.data.pic_url, (sp) => { this.icon_play.active = true;
this.sprite.spriteFrame = sp this.icon_stop.active = false;
this.sprite.node.width = this.node.width if (!this.audioId) return;
this.sprite.node.height = this.node.height cc.audioEngine.stop(this.audioId);
this.sprite.node.active = true return
})
}
if (this.data.useBorder) {
this.quan.active = true
}
this.handAnim.stop()
this.handAnim.node.active = false
if (!this._playing) {
this._playing = true
cc.systemEvent.once('stopMusic', this.onStopAudio, this)
let id = cc.audioEngine.play(this.tipClip)
cc.audioEngine.setFinishCallback(id, () => {
if (onlyOne != this) {
this._playing = false
return
}
let url = this.data.audio_url
if (url && url != '') {
this.playAudio(url)
} else {
this._playing = false
}
})
} }
if (this.data) {
this.quan.getComponent(cc.Sprite).spriteFrame = this.quan_lan;
// this.btnX.active = true
this.icon_stop.active = true
this.icon_play.active = false;
if (this.data.pic_url && this.data.gIdx == 0) {
tools.getSpriteFrimeByUrl(this.data.pic_url, (sp) => {
this.sprite.spriteFrame = sp
this.sprite.node.width = this.node.width
this.sprite.node.height = this.node.height
this.sprite.node.active = true
})
}
if (this.data.useBorder) {
this.quan.active = true
}
this.handAnim.stop()
this.handAnim.node.active = false
if (!this._playing) {
this._playing = true
cc.systemEvent.once('stopMusic', this.onStopAudio, this)
let id = cc.audioEngine.play(this.tipClip)
cc.audioEngine.setFinishCallback(id, () => {
if (onlyOne != this) {
this._playing = false
return
}
let url = this.data.audio_url
if (url && url != '') {
this.playAudio(url)
} else {
this._playing = false
}
})
}
if (onlyOne && onlyOne != this) { if (onlyOne && onlyOne != this) {
onlyOne.hideBox() onlyOne.hideBox()
}
onlyOne = this
} }
onlyOne = this if (this.timer) clearInterval(this.timer);
} this.timer = setInterval(() => {
if (!this._playing) {
if (this.timer) clearInterval(this.timer);
this.timer = null;
resolve('');
}
}, 60);
});
}, },
onClickHide() { onClickHide() {
...@@ -102,7 +126,8 @@ cc.Class({ ...@@ -102,7 +126,8 @@ cc.Class({
/**隐藏边框 */ /**隐藏边框 */
hideBox() { hideBox() {
this.quan.active = false this.quan.active = false
this.btnX.active = false // this.btnX.active = false
this.icon_stop.active = false
this.stopAudio() this.stopAudio()
}, },
...@@ -113,8 +138,8 @@ cc.Class({ ...@@ -113,8 +138,8 @@ cc.Class({
if (!this._playing) return if (!this._playing) return
this.audioId = cc.audioEngine.play(audioClip, false, 0.8); this.audioId = cc.audioEngine.play(audioClip, false, 0.8);
cc.audioEngine.setFinishCallback(this.audioId, this.stopAudio.bind(this)); cc.audioEngine.setFinishCallback(this.audioId, this.stopAudio.bind(this));
this.tipsAnim.node.active = true // this.tipsAnim.node.active = true
this.tipsAnim.play() // this.tipsAnim.play()
}); });
}, },
...@@ -128,8 +153,11 @@ cc.Class({ ...@@ -128,8 +153,11 @@ cc.Class({
cc.audioEngine.stop(this.audioId) cc.audioEngine.stop(this.audioId)
this.audioId = null this.audioId = null
} }
this.tipsAnim.stop() // this.tipsAnim.stop()
this.tipsAnim.node.active = false // this.tipsAnim.node.active = false
//变成黄色框框
this.quan.getComponent(cc.Sprite).spriteFrame = this.quan_huang;
this.icon_stop.active = false;
cc.systemEvent.off('stopMusic', this.onStopAudio, this) cc.systemEvent.off('stopMusic', this.onStopAudio, this)
}, },
/** 音频id */ /** 音频id */
......
...@@ -62,7 +62,28 @@ cc.Class({ ...@@ -62,7 +62,28 @@ cc.Class({
} }
}) })
}, },
autoTouchAll() {
if (!this.autoPlay) {
this.autoPlay = true;
this.items = this._items.children;
this.count = 0;
this.play();
}
},
play() {
if (!this.autoPlay) return cc.systemEvent.emit('stopAutoPlay');
let item = this.items[this.count++];
if (!item) return cc.systemEvent.emit('stopAutoPlay');
item.getComponent('hitItem').onTouchStart().then(() => {
this.play()
});
},
stopTouchAll() {
if (this.autoPlay) {
this.autoPlay = false;
cc.systemEvent.emit('stopMusic')
}
},
/** 清除item */ /** 清除item */
clearItems() { clearItems() {
this._items.removeAllChildren(true) this._items.removeAllChildren(true)
......
This diff is collapsed.
...@@ -20,6 +20,18 @@ cc.Class({ ...@@ -20,6 +20,18 @@ cc.Class({
type: cc.Node, type: cc.Node,
default: null default: null
}, },
pageNumNode: {
type: cc.Node,
default: null
},
movepageNode: {
type: cc.Node,
default: null
},
btn_audio: {
type: cc.Node,
default: null
},
btnClip: cc.AudioClip btnClip: cc.AudioClip
}, },
...@@ -156,6 +168,11 @@ cc.Class({ ...@@ -156,6 +168,11 @@ cc.Class({
initView() { initView() {
this.initBg(); this.initBg();
this.initPic(); this.initPic();
this.initEvent();
},
initEvent() {
this.movepageNode.on(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this)
cc.systemEvent.on('stopAutoPlay', this.stopAll, this);
}, },
initBg() { initBg() {
...@@ -182,12 +199,25 @@ cc.Class({ ...@@ -182,12 +199,25 @@ cc.Class({
}, },
curPage: null, curPage: null,
onTouchEnd(e) {
let touch = e.touch;
let startPoint = touch.getStartLocation();
let endPoint = touch.getLocation();
let moveX = endPoint.x - startPoint.x;
if (moveX < -100) {
this.onClickRight();
} else if (moveX > 100) {
this.onClickLeft();
}
},
onClickRight() { onClickRight() {
if (!this._cantouch) { if (!this._cantouch) {
return; return;
} }
this.curPage += 1 this.curPage += 1
if (this.curPage == this.data.length) this.curPage = 0;
if (this.curPage == 1) { if (this.curPage == 1) {
this.leftNode.active = true this.leftNode.active = true
...@@ -220,18 +250,26 @@ cc.Class({ ...@@ -220,18 +250,26 @@ cc.Class({
cc.audioEngine.play(this.btnClip, false, 0.8) cc.audioEngine.play(this.btnClip, false, 0.8)
}, },
//绑定音频按钮,点击按钮播放,再次点击按钮暂停 //绑定音频按钮,点击按钮播放,再次点击按钮暂停
onClickAudio(e) { onClickAudio(e) {
let target = e.target;
let btn_loop = target.getComponent("btn_loop");//找到btn_loop
if (this.isPlaying) { if (this.isPlaying) {
this.isPlaying = false; this.stopAll();
btn_loop.stopPlay();//执行暂停的方法
} else { } else {
this.isPlaying = true; this.playAll();
btn_loop.startPlay();//执行播放的方法
} }
}, },
playAll() {
this.isPlaying = true;
let btn_loop = this.btn_audio.getComponent("btn_loop");//找到btn_loop
btn_loop.startPlay();//执行播放的方法
this.picNode.getComponent('picNode').autoTouchAll()
},
stopAll() {
this.isPlaying = false;
let btn_loop = this.btn_audio.getComponent("btn_loop");//找到btn_loop
btn_loop.stopPlay();//执行暂停的方法
this.picNode.getComponent('picNode').stopTouchAll()
},
/** 左移动 */ /** 左移动 */
leftMove() { leftMove() {
this.stopAudio() this.stopAudio()
...@@ -289,7 +327,11 @@ cc.Class({ ...@@ -289,7 +327,11 @@ cc.Class({
return return
} }
picNode.getComponent('picNode').initWithData(data) picNode.getComponent('picNode').initWithData(data)
} },
// ------------------------------------------ // ------------------------------------------
update() {
this.pageNumNode.getChildByName("text").getComponent(cc.Label).string = (this.curPage % this.data.length + 1) + "/" + this.data.length
}
}); });
//3.自动连读
\ 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