Commit 21e91fae authored by yu's avatar yu

1

parent baa47a6f
This diff is collapsed.
import { asyncDelay, onHomeworkFinish } from "../script/util";
import { asyncDelay, onHomeworkFinish, RandomInt } from "../script/util";
import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent";
import Game from "./Game";
import pg from "./pg";
......@@ -87,7 +87,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.showGame();
}
private touchOver() {
this.playLocalAudio("finish"); let data: any = {};
this.playLocalAudio("finish"); let data: any = {};
let questions = this.logs.concat();
let score = 0;
questions.forEach(q => {
......@@ -102,11 +102,14 @@ export default class SceneComponent extends MyCocosSceneComponent {
setTimeout(() => {
let btn_check = cc.find("btn_check", this.node);
btn_check.getComponent(cc.Button).interactable = true;
// const bg = cc.find('Canvas/group_item', this.node);
this.showAllFirework(this.node, cc.find('Canvas/petal').children);
// let mouse_end = pg.view.find(this, "mouse_end");
// mouse_end.active = true;
// mouse_end.getComponent("mrbr04_mouse_end").play().then(() => {
//结算
// })
}, 1);
}
......@@ -565,6 +568,79 @@ export default class SceneComponent extends MyCocosSceneComponent {
//撒花 ------------------------------------------
async showOneFirework(pos, parentNode, nodeList) {
for (let i = 0; i < 3; i++) {
this.showFirework(pos, parentNode, nodeList, 200, 200, 15);
await asyncDelay(0.1);
}
}
async showAllFirework(parentNode, nodeList) {
for (let i = 0; i < 6; i++) {
this.showFirework(cc.v2(0, -parentNode.height / 2), parentNode, nodeList, parentNode.width * 2 / 3, parentNode.height * 1.3);
await asyncDelay(0.1);
}
}
showFirework(pos, parentNode, nodeList, width = 200, height = 200, number = 30) {
for (let i = 0; i < number; i++) {
const quad = this.createQuads(pos, parentNode, nodeList);
const targetX = RandomInt(width / 2, -width / 2);
const targetY = RandomInt(height);
cc.tween(quad)
.by(0.5, { x: targetX })
.by(3, { x: targetX * 2 })
.start();
cc.tween(quad)
.by(0.5, { y: targetY }, { easing: 'quadOut' })
.to(4, { y: -parentNode.height * 2 }, { easing: 'quadIn' })
.removeSelf()
.start();
cc.tween(quad)
.delay(1)
.to(1.5, { opacity: 0 })
.start();
}
}
createQuads(pos, parentNode, nodeList) {
const quadBase = cc.instantiate(nodeList[RandomInt(nodeList.length)]);
quadBase.x = pos.x;
quadBase.y = pos.y;
quadBase.z = pos.z;
quadBase.angle = RandomInt(180);
// quadBase.parent = parentNode;
parentNode.addChild(quadBase, 999);
const quad = quadBase.getChildByName('quad');
quad.x = 0;
quad.y = 0;
quad.angle = RandomInt(180);
const paper = quad.getChildByName('petal');
paper.scaleX = Math.random() * 0.5 + 0.5;
paper.scaleY = Math.random() * 0.5 + 0.5;
quadBase.scaleX = Math.random();
cc.tween(quadBase)
.to((1 - quadBase.scaleX) * 0.3, { scaleX: 1 })
.call(() => {
const time = Math.random() * 0.2;
cc.tween(quadBase)
.to(0.1 + time, { scaleX: -1 })
.to(0.1 + time, { scaleX: 1 })
.union()
.repeatForever()
.start();
})
.start();
return quadBase;
}
......
This diff is collapsed.
{
"ver": "1.2.9",
"uuid": "83963dc9-a6cd-4968-874c-9f540e527ec5",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "32efe837-eb1a-4ee9-9e87-465ad5c2bc92",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 29,
"height": 29,
"platformSettings": {},
"subMetas": {
"petal": {
"ver": "1.0.4",
"uuid": "62d10560-333c-410c-8353-c7d27e2b0018",
"rawTextureUuid": "32efe837-eb1a-4ee9-9e87-465ad5c2bc92",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 29,
"height": 29,
"rawWidth": 29,
"rawHeight": 29,
"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