Commit d1638871 authored by Tt's avatar Tt

音效添加完成

parent 964c8b01
{
"ver": "2.0.1",
"uuid": "816d8590-0603-4136-ab5b-9940e8616a2d",
"downloadMode": 0,
"duration": 1.306122,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "afb37858-5693-40e2-b4f9-156c2536bbef",
"downloadMode": 0,
"duration": 1.828571,
"subMetas": {}
}
\ No newline at end of file
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
const { ccclass, property } = cc._decorator;
@ccclass
export default class NewClass extends cc.Component {
@property
firstUp: boolean = true;
// LIFE-CYCLE CALLBACKS:
onLoad() {
if (this.firstUp) {
cc.tween(this.node).repeatForever(
cc.tween()
.by(10, { y: 25 })
.by(10, { y: -25 })
.by(10, { y: -25 })
.by(10, { y: 25 })
).start();
} else {
cc.tween(this.node).repeatForever(
cc.tween()
.by(10, { y: -25 })
.by(10, { y: 25 })
.by(10, { y: 25 })
.by(10, { y: -25 })
).start();
}
}
start() {
}
// update (dt) {}
}
{
"ver": "1.0.8",
"uuid": "4937e51d-fabc-4acf-a0c7-d6d5bce868b0",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
const { ccclass, property } = cc._decorator;
@ccclass
export default class NewClass extends cc.Component {
@property
firstUp: boolean = true;
// LIFE-CYCLE CALLBACKS:
onLoad() {
if (this.firstUp) {
cc.tween(this.node).repeatForever(
cc.tween()
.to(10, { scale: 0.97 })
.to(10, { scale: 1.00 })
.to(10, { scale: 1.03 })
.to(10, { scale: 1.00 })
).start();
} else {
cc.tween(this.node).repeatForever(
cc.tween()
.to(10, { scale: 1.03 })
.to(10, { scale: 1.00 })
.to(10, { scale: 0.97 })
.to(10, { scale: 1.00 })
).start();
}
}
start() {
}
// update (dt) {}
}
{
"ver": "1.0.8",
"uuid": "dd0efcab-7baa-485c-8197-5c9fabdee674",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
...@@ -42,12 +42,10 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -42,12 +42,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
pg.event.clear(); pg.event.clear();
} }
_cantouch = null;
initData() { initData() {
Game.getIns().init(this.data); Game.getIns().init(this.data);
Game.getIns().reset(); Game.getIns().reset();
// 所有全局变量 默认都是null this.touching = null;
this._cantouch = true;
} }
private audioId: any; private audioId: any;
async initView() { async initView() {
...@@ -57,14 +55,45 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -57,14 +55,45 @@ export default class SceneComponent extends MyCocosSceneComponent {
pg.view.setString(pg.view.find(boat_right, 'text'), Game.getIns().boatRight.text) pg.view.setString(pg.view.find(boat_right, 'text'), Game.getIns().boatRight.text)
} }
initEvent() { initEvent() {
pg.event.on("game_time_over", () => { pg.view.touchOn(pg.view.find(this, 'layout_bottom/boat_left/boat'), this.onTouchBoatLeft, this)
// alert("game_time_over") pg.view.touchOn(pg.view.find(this, 'layout_bottom/boat_right/boat'), this.onTouchBoatRight, this)
//这里的事件会发送的很早。但是我们需要等待动画执行完了之后再开始后续的内容 }
Game.getIns().addPage(); onTouchBoatLeft() {
if (!Game.getIns().isOver) { let voice = pg.view.find(this, 'layout_bottom/boat_left/boat/voice')
return; let count = 0;
} voice.active = true;
this.showGameOver(); function func() {
pg.view.find(voice, 'v1').active = count % 4 == 1;
pg.view.find(voice, 'v2').active = count % 4 == 2;
pg.view.find(voice, 'v3').active = count % 4 == 3;
count++;
}
this.schedule(func, 0.3)
pg.audio.playAudioByUrlThen(Game.getIns().boatLeft.audio).then(() => {
this.unschedule(func)
pg.view.find(voice, 'v1').active = false;
pg.view.find(voice, 'v2').active = false;
pg.view.find(voice, 'v3').active = false;
voice.active = false;
})
}
onTouchBoatRight() {
let voice = pg.view.find(this, 'layout_bottom/boat_right/boat/voice')
let count = 0;
voice.active = true;
function func() {
pg.view.find(voice, 'v1').active = count % 4 == 1;
pg.view.find(voice, 'v2').active = count % 4 == 2;
pg.view.find(voice, 'v3').active = count % 4 == 3;
count++;
}
this.schedule(func, 0.3)
pg.audio.playAudioByUrlThen(Game.getIns().boatRight.audio).then(() => {
this.unschedule(func)
pg.view.find(voice, 'v1').active = false;
pg.view.find(voice, 'v2').active = false;
pg.view.find(voice, 'v3').active = false;
voice.active = false;
}) })
} }
...@@ -148,7 +177,9 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -148,7 +177,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
fishList.forEach((fish, index) => { fishList.forEach((fish, index) => {
let node = cc.instantiate(item); let node = cc.instantiate(item);
layout_fish.addChild(node); layout_fish.addChild(node);
this.updateItem(node, fish); this.scheduleOnce(() => {
this.updateItem(node, fish);
}, index * Math.random())
}); });
} }
updateItem(item, data: Option) { updateItem(item, data: Option) {
...@@ -200,23 +231,26 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -200,23 +231,26 @@ export default class SceneComponent extends MyCocosSceneComponent {
item.x = pos.x; item.x = pos.x;
item.y = pos.y; item.y = pos.y;
} }
private touching: any;
onItemTouchStart(e) { onItemTouchStart(e) {
if (this.touching) return;
let target: cc.Node = e.target; let target: cc.Node = e.target;
let data = target.data; let data: Option = target.data;
if (data.isChecked) return;
this.setTouchPos(e); this.setTouchPos(e);
this.touching = data;
} }
onItemTouchMove(e) { onItemTouchMove(e) {
let target: cc.Node = e.target; let target: cc.Node = e.target;
let data = target.data; let data = target.data;
if (data.isChecked) return; if (!this.touching) return;
if (this.touching.id != data.id) return;
this.setTouchPos(e); this.setTouchPos(e);
} }
onItemTouchEnd(e) { onItemTouchEnd(e) {
//
let target: cc.Node = e.target; let target: cc.Node = e.target;
let data = target.data; let data = target.data;
if (data.isChecked) return; if (!this.touching) return;
if (this.touching.id != data.id) return;
// let rect = cc.rect(target.x, target.y, target.width, target.height); // let rect = cc.rect(target.x, target.y, target.width, target.height);
let rect = cc.rect(target.x, target.y, 50, 50); let rect = cc.rect(target.x, target.y, 50, 50);
...@@ -236,11 +270,27 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -236,11 +270,27 @@ export default class SceneComponent extends MyCocosSceneComponent {
Game.getIns().boatRight.setRight(data); Game.getIns().boatRight.setRight(data);
currentRect = rightRect; currentRect = rightRect;
} }
if (!currentRect) return; if (!currentRect) {
this.touching = null;
this.playLocalAudio('error').then(() => {
this.touching = null;
this.updateItem(target, data);
})
return;
}
if (isRight) { if (isRight) {
// target
let item = target; let item = target;
let lastArea = 100; let lastArea = 100;
this.playLocalAudio('right').then(() => {
if (data.audioUrl) {
pg.audio.playAudioByUrlThen(data.audioUrl).then(() => {
this.touching = null;
})
} else {
this.touching = null;
}
})
if (item.scaleX == -1) { if (item.scaleX == -1) {
// 计算当前坐标距离最左侧的距离 // 计算当前坐标距离最左侧的距离
let space = currentRect.width - ((rect.x + rect.width) - currentRect.x) - lastArea / 5; let space = currentRect.width - ((rect.x + rect.width) - currentRect.x) - lastArea / 5;
...@@ -258,7 +308,10 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -258,7 +308,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
item.off(cc.Node.EventType.TOUCH_CANCEL, this.onItemTouchCancel, this); item.off(cc.Node.EventType.TOUCH_CANCEL, this.onItemTouchCancel, this);
pg.event.emit('mouse_05_add') pg.event.emit('mouse_05_add')
} else { } else {
this.updateItem(target, data); this.playLocalAudio('error').then(() => {
this.touching = null;
this.updateItem(target, data);
})
} }
//判断是否结束了 //判断是否结束了
if (Game.getIns().boatLeft.isAllRight() && Game.getIns().boatRight.isAllRight()) { if (Game.getIns().boatLeft.isAllRight() && Game.getIns().boatRight.isAllRight()) {
......
{
"ver": "1.1.2",
"uuid": "d427b42b-3b60-403a-a224-7b0137a16c06",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "8f1ed432-166d-4cdc-8dab-c545657b906e",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 52,
"height": 76,
"platformSettings": {},
"subMetas": {
"v1": {
"ver": "1.0.4",
"uuid": "dc635d80-da93-4f22-b4f0-b182682262c2",
"rawTextureUuid": "8f1ed432-166d-4cdc-8dab-c545657b906e",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 19.5,
"offsetY": 2,
"trimX": 40,
"trimY": 24,
"width": 11,
"height": 24,
"rawWidth": 52,
"rawHeight": 76,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "54bab549-e6ae-4d18-bec1-2c485ce342a8",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 52,
"height": 76,
"platformSettings": {},
"subMetas": {
"v2": {
"ver": "1.0.4",
"uuid": "6601c88f-dfbf-4ccb-9ff6-e44377e3bf66",
"rawTextureUuid": "54bab549-e6ae-4d18-bec1-2c485ce342a8",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 10.5,
"offsetY": 2,
"trimX": 22,
"trimY": 12,
"width": 29,
"height": 48,
"rawWidth": 52,
"rawHeight": 76,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "f40b630a-635c-497a-8a8c-9b6bc74fce0d",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 52,
"height": 76,
"platformSettings": {},
"subMetas": {
"v3": {
"ver": "1.0.4",
"uuid": "195ea49e-9f29-4b2e-8baf-cfe83f99fafc",
"rawTextureUuid": "f40b630a-635c-497a-8a8c-9b6bc74fce0d",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 1,
"trimY": 1,
"width": 50,
"height": 74,
"rawWidth": 52,
"rawHeight": 76,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ 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