Commit 38c5f54d authored by wildfirecode's avatar wildfirecode

1

parent 771d7e29
No preview for this file type
export default class Effect extends egret.Sprite {
import Body from "./playScene/physics/Body";
import { sqrt3 } from "./playScene/physics/Const";
export default class Effect {
NUMS_MAX = 11;
start(type) {
_parent: egret.DisplayObjectContainer;
constructor(block: Body, parent: egret.DisplayObjectContainer) {
const resName = block.view['bg']['__resName__']
for (let i = 0; i < this.NUMS_MAX; i++) {
const data = this.createItem(1);
this.addChild(data.shape);
egret.Tween.get(data).to({}, 360);
const data = this.createItem(resName);
parent.addChild(data.shape);
data.shape.x = block.x;
data.shape.y = block.y;
egret.Tween.get(data.shape).to({ x: data.targetX + block.x, y: block.y + data.targetY, scaleY: 0, scaleX: 0 }, 360).call(() => {
data.shape.parent && data.shape.parent.removeChild(data.shape);
});
}
}
createItem(type) {
createItem(resName: string) {
const moveDisMax = 100;
const squareSize = 100;
const shape = new egret.Shape();
shape.graphics.beginFill(0xff0000);
shape.graphics.drawRect(-squareSize / 2, -squareSize / 2, squareSize, squareSize);
shape.graphics.endFill();
const shapeType = this.getShapeType(resName);
if (shapeType == 'circle') {
shape.graphics.beginFill(this.getShapeColor(resName));
shape.graphics.drawCircle(0, 0, squareSize / 2);
shape.graphics.endFill();
} else if (shapeType == 'tri') {
shape.graphics.beginFill(this.getShapeColor(resName));
shape.graphics.moveTo(0, -squareSize * sqrt3 / 3);
shape.graphics.lineTo(squareSize / 2, squareSize * sqrt3 / 6);
shape.graphics.lineTo(-squareSize / 2, squareSize * sqrt3 / 6);
shape.graphics.endFill();
} else if (shapeType == 'sq') {
shape.graphics.beginFill(this.getShapeColor(resName));
shape.graphics.drawRect(-squareSize / 2, -squareSize / 2, squareSize, squareSize);
shape.graphics.endFill();
}
const scale = Math.random() * 0.7 + 0.3;
const rotation = Math.random() * 360;
const angle = Math.random() * Math.PI * 2;
......@@ -23,6 +44,36 @@ export default class Effect extends egret.Sprite {
const targetX = Math.sin(angle) * dis;
const targetY = Math.cos(angle) * dis;
shape.scaleX = shape.scaleY = scale;
return { shape: shape };
shape.rotation = rotation;
return { shape: shape, targetX: targetX, targetY: targetY };
}
getShapeType(resName: string) {
if (resName == 'circle1_png')
return 'circle';
if (resName.indexOf('tri') > -1)
return 'tri';
if (resName.indexOf('sq') > -1)
return 'sq';
return 'circle'
}
getShapeColor(resName: string) {
if (resName == 'circle1_png')
return 0xffca55;
if (resName == 'sq1_png')
return 0xfa7782;
if (resName == 'sq2_png')
return 0xf677ce;
if (resName == 'sq3_png')
return 0xffac84;
if (resName == 'sq4_png')
return 0xffca55;
if (resName == 'tri1_png')
return 0x2db0ee;
if (resName == 'tri2_png')
return 0x86e45f;
return 0xffca55
}
}
\ No newline at end of file
......@@ -22,6 +22,7 @@ import { isSpecialBody, getLadderPosition, getLadderHPosition, getBounce, isSpec
import { getBlocks, resetCounter, getCounter } from "./blockGen";
import createSpeialCircle from "./factory/createSpeialCircle";
import { NetManager } from "../../libs/tw/manager/NetManager";
import Effect from "../Effect";
export default class PlayScene extends Scene {
initEvents() {
......@@ -271,6 +272,7 @@ export default class PlayScene extends Scene {
this.data.score++;
block.num = block.num - 1;
if (block.num <= 0) {
new Effect(block, this);
//回收加动效
this.removeEle(block, this.blocks);
this.removeChild(block.view);
......@@ -403,7 +405,7 @@ export default class PlayScene extends Scene {
blocks.forEach(block => {
console.log('ladderNums', block.ladderNums)
// if (block.ladderNums >= 1) {
if (block.ladderNums >= 9) {
if (block.ladderNums >= 9) {
failed = true;
}
});
......
......@@ -9,6 +9,7 @@ export default (that: PlayScene, x, y, num) => {
sprite.touchEnabled = sprite.touchChildren = false;
//背景
const shape = new egret.Bitmap(RES.getRes('circle1_png'));
shape['__resName__'] = 'circle1_png';
const radius = shape.width / 2;
const length = radius * 2;
shape.anchorOffsetX = shape.width / 2;
......@@ -35,5 +36,5 @@ export default (that: PlayScene, x, y, num) => {
block.y = y;
block.num = num;
that.blocks.push(block);
block.ladderNums=1;
block.ladderNums = 1;
}
\ No newline at end of file
......@@ -6,7 +6,7 @@ export default (that: PlayScene, x, y, num) => {
const picType = Math.ceil(Math.random() * 2);
const pic = new egret.Bitmap(RES.getRes(`tri${picType}_png`));
pic.anchorOffsetX = pic.width / 2;
pic.anchorOffsetY = pic.height *.65;
pic.anchorOffsetY = pic.height * .65;
if (!block) {
const sprite = new egret.Sprite();
sprite.touchEnabled = sprite.touchChildren = false;
......@@ -19,7 +19,7 @@ export default (that: PlayScene, x, y, num) => {
txt.width = length;
txt.height = length;
txt.anchorOffsetX = length / 2;
txt.anchorOffsetY = length /2;
txt.anchorOffsetY = length / 2;
txt.size = 26;
txt.textColor = 0xffffff;
txt.textAlign = egret.HorizontalAlign.CENTER;
......@@ -35,11 +35,12 @@ export default (that: PlayScene, x, y, num) => {
block.view.addChild(block.view['txt']);
}
}
block.view["bg"]['__resName__'] = `tri${picType}_png`;
that.addChild(block.view)
block.x = x;
block.y = y;
block.rotation = Math.random()*360;
block.rotation = Math.random() * 360;
block.num = num;
that.blocks.push(block);
block.ladderNums=1;
block.ladderNums = 1;
}
\ No newline at end of file
......@@ -6,7 +6,7 @@ export default (that: PlayScene, x, y, num) => {
const pic = new egret.Bitmap(RES.getRes(`sq${picType}_png`));
pic.anchorOffsetX = pic.width / 2;
pic.anchorOffsetY = pic.height / 2;
let block:Square = that.pool.takeOut("square");
let block: Square = that.pool.takeOut("square");
if (!block) {
const sprite = new egret.Sprite();
sprite.touchEnabled = sprite.touchChildren = false;
......@@ -38,12 +38,13 @@ export default (that: PlayScene, x, y, num) => {
block.view.addChild(block.view['txt']);
}
}
block.view["bg"]['__resName__'] = `sq${picType}_png`;
that.addChild(block.view)
block.x = x;
block.y = y;
block.num = num;
block.rotation = Math.random()*360;
block.rotation = Math.random() * 360;
// block.rotation = Math.random()>0.5 ? 0 : 45;
that.blocks.push(block);
block.ladderNums=1;
block.ladderNums = 1;
}
\ No newline at end of file
......@@ -9,6 +9,7 @@ import SceneCtrl from "../../libs/new_wx/ctrls/sceneCtrl";
import { ModuleTypes } from "../../libs/new_wx/types/sceneTypes";
import { DataManager } from "../../libs/tw/manager/DataManager";
import { NetManager } from "../../libs/tw/manager/NetManager";
import Effect from "../Effect";
export default class StartScene extends Scene {
ruleBtn: eui.Button;
......@@ -34,6 +35,14 @@ export default class StartScene extends Scene {
});
NetManager.ins.getPrizeInfo(() => { }, window['revivePlugId']);
// setTimeout(() => {
// const e = new Effect('circle1_png');
// this.addChild(e);
// e.x = 375;
// e.y = 500;
// }, 1000);
}
private updateGetInfoView() {
......
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