Commit decbabd3 authored by 唐鑫's avatar 唐鑫

游戏调整完成

parent ec2478ab
......@@ -33,13 +33,10 @@
"__id__": 20
},
{
"__id__": 23
},
{
"__id__": 26
"__id__": 24
},
{
"__id__": 29
"__id__": 28
},
{
"__id__": 32
......@@ -738,10 +735,13 @@
"_components": [
{
"__id__": 21
},
{
"__id__": 22
}
],
"_prefab": {
"__id__": 22
"__id__": 23
},
"_opacity": 255,
"_color": {
......@@ -765,8 +765,8 @@
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-29.336,
73.964,
-175.806,
81.931,
0,
0,
0,
......@@ -822,6 +822,33 @@
"_atlas": null,
"_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",
"root": {
......@@ -844,11 +871,14 @@
"_active": false,
"_components": [
{
"__id__": 24
"__id__": 25
},
{
"__id__": 26
}
],
"_prefab": {
"__id__": 25
"__id__": 27
},
"_opacity": 255,
"_color": {
......@@ -872,8 +902,8 @@
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-29.648,
74.275,
-176.078,
82.067,
0,
0,
0,
......@@ -902,7 +932,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 23
"__id__": 24
},
"_enabled": true,
"_materials": [
......@@ -930,110 +960,30 @@
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"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",
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 26
"__id__": 24
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "4b7d087b-846b-42be-a0fd-0680a9428b88"
},
"_type": 0,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"alignMode": 1,
"_target": null,
"_alignFlags": 9,
"_left": -21.578000000000003,
"_right": 0,
"_top": -48.06699999999999,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_id": ""
},
{
......@@ -1044,7 +994,7 @@
"asset": {
"__uuid__": "2ce7d58d-b6fe-4ef7-a128-de76f672a803"
},
"fileId": "f94BWi8LJI7LZb1nnh8wI/",
"fileId": "bdj7Z5C1hG9ZUpslIq23db",
"sync": false
},
{
......@@ -1057,6 +1007,9 @@
"_children": [],
"_active": false,
"_components": [
{
"__id__": 29
},
{
"__id__": 30
}
......@@ -1074,8 +1027,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 130,
"height": 130
"width": 397,
"height": 139
},
"_anchorPoint": {
"__type__": "cc.Vec2",
......@@ -1086,8 +1039,8 @@
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
14.364,
-3.482,
0,
0,
0,
0,
0,
......@@ -1116,7 +1069,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 29
"__id__": 28
},
"_enabled": true,
"_materials": [
......@@ -1143,6 +1096,33 @@
"_atlas": null,
"_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",
"root": {
......@@ -1618,7 +1598,7 @@
},
"_enabled": true,
"quan": {
"__id__": 29
"__id__": 28
},
"tipsAnim": {
"__id__": 4
......@@ -1639,7 +1619,13 @@
"__id__": 20
},
"icon_stop": {
"__id__": 23
"__id__": 24
},
"quan_lan": {
"__uuid__": "7651dd7c-f921-4f71-8006-4f25714d24b9"
},
"quan_huang": {
"__uuid__": "4b7d087b-846b-42be-a0fd-0680a9428b88"
},
"_id": ""
},
......
......@@ -12,6 +12,8 @@ cc.Class({
btnX: cc.Node,
icon_play: cc.Node,
icon_stop: cc.Node,
quan_lan: cc.SpriteFrame,
quan_huang: cc.SpriteFrame
},
data: null,
......@@ -21,7 +23,8 @@ cc.Class({
this.quan.active = false
this.tipsAnim.node.active = false
this.handAnim.node.active = false
this.btnX.active = false
// this.btnX.active = false
this.icon_stop.active = false
},
onEnable() {
......@@ -52,46 +55,67 @@ cc.Class({
},
onTouchStart() {
if (this._playing) return
if (this.audioId) return
if (this.data) {
this.btnX.active = true
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
}
})
return new Promise((resolve, reject) => {
if (this._playing || this.audioId) {
//增加暂停功能。
this._playing = false;
//播放切换
this.icon_play.active = true;
this.icon_stop.active = false;
if (!this.audioId) return;
cc.audioEngine.stop(this.audioId);
return
}
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) {
onlyOne.hideBox()
if (onlyOne && onlyOne != this) {
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() {
......@@ -102,7 +126,8 @@ cc.Class({
/**隐藏边框 */
hideBox() {
this.quan.active = false
this.btnX.active = false
// this.btnX.active = false
this.icon_stop.active = false
this.stopAudio()
},
......@@ -113,8 +138,8 @@ cc.Class({
if (!this._playing) return
this.audioId = cc.audioEngine.play(audioClip, false, 0.8);
cc.audioEngine.setFinishCallback(this.audioId, this.stopAudio.bind(this));
this.tipsAnim.node.active = true
this.tipsAnim.play()
// this.tipsAnim.node.active = true
// this.tipsAnim.play()
});
},
......@@ -128,8 +153,11 @@ cc.Class({
cc.audioEngine.stop(this.audioId)
this.audioId = null
}
this.tipsAnim.stop()
this.tipsAnim.node.active = false
// this.tipsAnim.stop()
// 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)
},
/** 音频id */
......
......@@ -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 */
clearItems() {
this._items.removeAllChildren(true)
......
This diff is collapsed.
......@@ -20,6 +20,18 @@ cc.Class({
type: cc.Node,
default: null
},
pageNumNode: {
type: cc.Node,
default: null
},
movepageNode: {
type: cc.Node,
default: null
},
btn_audio: {
type: cc.Node,
default: null
},
btnClip: cc.AudioClip
},
......@@ -156,6 +168,11 @@ cc.Class({
initView() {
this.initBg();
this.initPic();
this.initEvent();
},
initEvent() {
this.movepageNode.on(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this)
cc.systemEvent.on('stopAutoPlay', this.stopAll, this);
},
initBg() {
......@@ -182,12 +199,25 @@ cc.Class({
},
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() {
if (!this._cantouch) {
return;
}
this.curPage += 1
if (this.curPage == this.data.length) this.curPage = 0;
if (this.curPage == 1) {
this.leftNode.active = true
......@@ -220,18 +250,26 @@ cc.Class({
cc.audioEngine.play(this.btnClip, false, 0.8)
},
//绑定音频按钮,点击按钮播放,再次点击按钮暂停
//绑定音频按钮,点击按钮播放,再次点击按钮暂停
onClickAudio(e) {
let target = e.target;
let btn_loop = target.getComponent("btn_loop");//找到btn_loop
if (this.isPlaying) {
this.isPlaying = false;
btn_loop.stopPlay();//执行暂停的方法
this.stopAll();
} else {
this.isPlaying = true;
btn_loop.startPlay();//执行播放的方法
this.playAll();
}
},
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() {
this.stopAudio()
......@@ -289,7 +327,11 @@ cc.Class({
return
}
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