Commit a1462a33 authored by yu's avatar yu

1

parent beb2c3dd
// pg.event.emit('img_voice_play_voice_start')
// pg.event.emit('img_voice_play_voice_end')
import pg from "../../scene/pg_hy05_pintu";
......@@ -8,13 +10,15 @@ const { ccclass, property } = cc._decorator;
@ccclass
export default class Candy extends cc.Component {
private img_npc_voice: cc.Node;
@property(cc.Float)
private jumpHeight: number = 80;
@property(cc.Boolean)
private isHide: boolean = false;
onLoad() {
this.initView();
this.playVoiceStart();
}
initView() {
this.img_npc_voice = this.node;
}
initEvent() {
// pg.event.on('img_voice_play_voice_start', () => {
......@@ -26,17 +30,24 @@ export default class Candy extends cc.Component {
private playVoiceCount: number;
playVoiceStart() {
this.node.children.forEach((ch) => {
this.node.children.forEach((ch, idx) => {
let x = ch.x;
let y = ch.y;
ch.x = 0;
ch.y = 0;
let ju = cc.jumpBy(0.5, cc.v2(x, y), 80, 1);
ch.runAction(ju);
let ju = cc.jumpBy(0.5, cc.v2(x, y), this.jumpHeight, 1);
let call = cc.callFunc(() => {
if (idx == this.node.children.length - 1)
pg.event.emit("camdy_action_end", this.node);
if (this.isHide) this.node.active = !this.isHide;
})
// ch.runAction(ju);
cc.tween(ch).sequence(ju, call).start();
})
}
playVoiceRunning() {
......
export let imageZize = {
width: 960,
height: 608
}
export class OptionJigsaw {
type;
txt;
......@@ -118,8 +124,8 @@ export default class GameJigsaw {
}
public pointsArr;
private changepoints(data) {
let scX = 960 / data.bgItem.rect.width;
let scY = 608 / data.bgItem.rect.height;
let scX = imageZize.width / data.bgItem.rect.width;
let scY = imageZize.height / data.bgItem.rect.height;
let px = data.bgItem.rect.x;
let py = data.bgItem.rect.y;
this.pointsArr = [];
......
This source diff could not be displayed because it is too large. You can view the blob instead.
import { asyncDelay, exchangeNodePos, getSprNode, onHomeworkFinish, onHomeworkStart, playAudio } from "../script/util_hy05_pintu";
import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent_hy05_pintu";
import GameJigsaw, { ItemJigsaw, OptionJigsaw } from "./Gamehy05_pintu";
import GameJigsaw, { imageZize, ItemJigsaw, OptionJigsaw } from "./Gamehy05_pintu";
import pg from "./pg_hy05_pintu";
const { ccclass, property } = cc._decorator;
......@@ -42,7 +42,8 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent {
sort_card: cc.Node = null;
@property(cc.Node)
big_item: cc.Node = null;
img_bg: cc.Node = null;
@property(cc.Node)
layer_right: cc.Node = null;
......@@ -60,14 +61,13 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent {
this.cardBgs = [];
}
initView() {
this.flyAction();
this.startGame();
let itembg = cc.find("itembg", this.node);
pg.view.setNetImg(itembg, GameJigsaw.getIns().image, { w: 960, h: 608 });
pg.view.setNetImg(this.img_bg, GameJigsaw.getIns().image, { w: imageZize.width, h: imageZize.height });
}
initEvent() {
pg.view.touchOn(cc.find("btn_close", this.big_item), this.onCloseBigItem, this);
pg.view.touchOn(this.btn_up, this.onScUp, this);
pg.view.touchOn(this.btn_down, this.onScDown, this);
......@@ -87,7 +87,7 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent {
this.btn_down.active = height > 450;
}
private scrollEnd(e) {
let rightSc = cc.find("rightSc", this.node).getComponent(cc.ScrollView);
let off = rightSc.getScrollOffset();
......@@ -105,9 +105,7 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent {
let off = rightSc.getScrollOffset();
rightSc.scrollToOffset(cc.v2(0, off.y + 258), 0.5);
}
private onCloseBigItem() {
this.big_item.active = false;
}
//根据两点获取距离
private getDistance(p1, p2) {
......@@ -156,11 +154,11 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent {
this.layout_sort.removeAllChildren();
let count = 0;
list.forEach(li => {
list.forEach((li, idx) => {
let item = cc.instantiate(this.node_card);
this.right_layout.addChild(item);
li.count = count;
this.initTopCard(item, li);
this.initTopCard(item, li, idx);
count++;
})
count = 0;
......@@ -178,13 +176,15 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent {
this.cardBgs.push(item);
})
}
private initTopCard(item, data) {
private initTopCard(item, data, idx) {
let img = cc.find("img", item);
pg.view.setNetImg(img, data.image, { w: 118, h: 118 }, false);
img.x = idx % 2 == 0 ? -107 : 107
item.active = true;
item.y = 0;
item.x = 0;
img.data = data;
img.data.pos = img.getPosition();
item.data = data;
img.scale = 0.9;
img.on(cc.Node.EventType.TOUCH_START, this.onItemTouchStart, this);
......@@ -193,14 +193,7 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent {
img.on(cc.Node.EventType.TOUCH_CANCEL, this.onItemTouchCancel, this);
// item.on(cc.Node.EventType.TOUCH_END, this.onItem, this);
}
private onItem(e) {
let target: cc.Node = e.target;
let image = cc.find("img", this.big_item);
pg.view.setNetImg(image, target.data.image, { w: 200, h: 200 }, false);
image.scale = 1.5;
this.big_item.active = true;
this.big_item.zIndex = 60;
}
private setTouchPos(e) {
let location = e.getLocation();
let size = cc.view.getCanvasSize();
......@@ -251,7 +244,7 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent {
if (this.getDistance(target.startPos, target.getPosition()) < 30) {//&& target.parent.name != "Canvas"
// this.onItem(e);
target.parent = this.right_layout.children[data.count];
target.setPosition(0, 0);
target.setPosition(data.pos);
// this.playLocalAudio("big");
target.scale = 0.9;
return;
......@@ -271,7 +264,7 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent {
let isIn = this.rectCollect(target, this.layout_sort);
if (!itemBg && !isIn) {
target.parent = this.right_layout.children[data.count];
target.setPosition(0, 0);
target.setPosition(data.pos);
// this.playLocalAudio("error");
target.scale = 0.9;
return;
......@@ -292,10 +285,10 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent {
//每一个设置都要设置成中心点?
target.setPosition(0, 0);//-target.parent.height / 2
target.setAnchorPoint(0.5, 0.5)
itemBg.getChildByName("particle_star").active = true;
setTimeout(() => {
itemBg.getChildByName("particle_star").active = false;
}, 1000);
itemBg.getChildByName("layer_candy").active = true;
// setTimeout(() => {
// itemBg.getChildByName("layer_candy").active = false;
// }, 1000);
if (this.checkRoundEnd()) {
GameJigsaw.getIns().addPage();
......@@ -305,8 +298,13 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent {
this.playLocalAudio("error");
}
}
onItemTouchCancel() {
onItemTouchCancel(e) {
let target: cc.Node = e.target;
let data = target.data;
target.parent = this.right_layout.children[data.count];
target.setPosition(data.pos);
// this.playLocalAudio("error");
target.scale = 0.9;
}
private cleanLayoutSort() {
this.cardBgs.forEach((item) => {
......@@ -333,7 +331,7 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent {
}
gameOver() {
this.layer_right.active = true;
pg.event.emit("layer_right_show_excellent");
// this.playLocalAudio("over");
......@@ -352,7 +350,21 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent {
// });
// });
}
private flyAction() {
let image_aircraft = cc.find("bg/image_aircraft", this.node);
image_aircraft.setPosition(1200, 300);
cc.tween(image_aircraft).repeatForever(cc.tween(image_aircraft).to(10, { x: 0, y: 50 }).to(10, { x: -1200, y: 300 })
.call(() => {
image_aircraft.setPosition(1200, 300);
})).start();
}
playLocalAudio(audioName) {
const audio = cc.find(`Canvas/res/audio/${audioName}`).getComponent(cc.AudioSource);
return new Promise((resolve, reject) => {
......
{
"ver": "2.3.5",
"uuid": "80b08557-c191-4a22-9ace-7ae9d8a27459",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 967,
"height": 607,
"platformSettings": {},
"subMetas": {
"TEXT": {
"ver": "1.0.4",
"uuid": "79aee1ab-3f48-4f0c-a4a0-3de612d38122",
"rawTextureUuid": "80b08557-c191-4a22-9ace-7ae9d8a27459",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 967,
"height": 607,
"rawWidth": 967,
"rawHeight": 607,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "15ffa8c1-2c71-4161-9593-72d8d47e5730",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 310,
"height": 168,
"platformSettings": {},
"subMetas": {
"image_aircraft": {
"ver": "1.0.4",
"uuid": "24174210-4feb-41af-a1ed-e50e529c8c0d",
"rawTextureUuid": "15ffa8c1-2c71-4161-9593-72d8d47e5730",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 310,
"height": 168,
"rawWidth": 310,
"rawHeight": 168,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "f5d13701-cda5-4ed1-b9b8-f262c2f2b71c",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 1098,
"height": 738,
"platformSettings": {},
"subMetas": {
"itembg": {
"ver": "1.0.4",
"uuid": "c1c9b3d5-148c-49b2-a0cc-122882c0e44a",
"rawTextureUuid": "f5d13701-cda5-4ed1-b9b8-f262c2f2b71c",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -7,
"offsetY": 13.5,
"trimX": 60,
"trimY": 51,
"width": 964,
"height": 609,
"rawWidth": 1098,
"rawHeight": 738,
"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