Commit 1514e0ea authored by wildfirecode's avatar wildfirecode

1

parent 417b6dd0
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
"globalBackgroundWidth": -1, "globalBackgroundWidth": -1,
"globalBackgroundHeight": -1, "globalBackgroundHeight": -1,
"globalBackgroundColor": "#ffffff", "globalBackgroundColor": "#ffffff",
"globalBackgroundImage": "/Users/wanghongyuan/db-game-template/egret/resource/assets/startScene/startscenebg.jpg" "globalBackgroundImage": ""
}, },
"1667fb18fa6": { "1667fb18fa6": {
"bindingDataTestObj": [ "bindingDataTestObj": [
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
"backgroundY": 0, "backgroundY": 0,
"backgroundWidth": -1, "backgroundWidth": -1,
"backgroundHeight": -1, "backgroundHeight": -1,
"useBgImage": true, "useBgImage": false,
"useBgColor": true "useBgColor": true
} }
} }
\ No newline at end of file
...@@ -79,7 +79,7 @@ ...@@ -79,7 +79,7 @@
</script> </script>
<script src="output.js"></script> <script src="output.js"></script>
<!-- <div id="debugCanvas" style="position:absolute;opacity: 0.9;pointer-events: none"></div> --> <!-- <div id="debugCanvas" style="position:absolute;opacity: 0.7;pointer-events: none"></div> -->
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -22,8 +22,9 @@ export default class SceneCtrl { ...@@ -22,8 +22,9 @@ export default class SceneCtrl {
const key = scene.skinKey.toLowerCase(); const key = scene.skinKey.toLowerCase();
const promise = Promise.all([ const promise = Promise.all([
RES.getResAsync(`${key}_json`), RES.getResAsync(`${key}_json`),
RES.getResAsync(`${key}_png`), RES.getResAsync(`${key}_png`)//,
RES.getResAsync(`${key}scenebg_jpg`)]); // RES.getResAsync(`${key}scenebg_jpg`)
]);
promise.then(() => { promise.then(() => {
this.showAfterLoadAtlas(scene, data, onComplete); this.showAfterLoadAtlas(scene, data, onComplete);
}); });
......
{"options":{"layoutMath":"2","sizeMode":"2n","useExtension":1,"layoutGap":1,"extend":0},"projectName":"preload","version":5,"files":["../assets/startScene/basket_bottom.png"]}
\ No newline at end of file
{"options":{"layoutMath":"2","sizeMode":"2n","useExtension":1,"layoutGap":1,"extend":0},"projectName":"start","version":5,"files":["../assets/startScene/basket_top.png","../assets/startScene/bubble.png","../assets/startScene/glass.png","../assets/startScene/optionBtn.png","../assets/startScene/rankBtn.png","../assets/startScene/recordbtn.png","../assets/startScene/ruleBtn.png","../assets/startScene/start_btn_gray.png","../assets/startScene/start_btn.png"]} {"options":{"layoutMath":"2","sizeMode":"2n","useExtension":1,"layoutGap":1,"extend":0},"projectName":"start","version":5,"files":["../assets/startScene/basket_bottom.png","../assets/startScene/basket_top.png","../assets/startScene/bubble.png","../assets/startScene/glass.png","../assets/startScene/optionBtn.png","../assets/startScene/rankBtn.png","../assets/startScene/recordbtn.png","../assets/startScene/ruleBtn.png","../assets/startScene/start_btn_gray.png","../assets/startScene/start_btn.png"]}
\ No newline at end of file \ No newline at end of file
{"file":"fail.png","frames":{
"2":{"x":285,"y":585,"w":244,"h":259,"offX":276,"offY":307,"sourceW":750,"sourceH":750},
"3":{"x":614,"y":301,"w":280,"h":285,"offX":262,"offY":287,"sourceW":750,"sourceH":750},
"4":{"x":614,"y":0,"w":297,"h":299,"offX":253,"offY":278,"sourceW":750,"sourceH":750},
"5":{"x":310,"y":0,"w":302,"h":312,"offX":248,"offY":271,"sourceW":750,"sourceH":750},
"6":{"x":0,"y":0,"w":308,"h":306,"offX":242,"offY":273,"sourceW":750,"sourceH":750},
"7":{"x":285,"y":314,"w":280,"h":269,"offX":241,"offY":287,"sourceW":750,"sourceH":750},
"8":{"x":0,"y":308,"w":283,"h":276,"offX":241,"offY":283,"sourceW":750,"sourceH":750},
"1":{"x":913,"y":0,"w":67,"h":66,"offX":350,"offY":385,"sourceW":750,"sourceH":750}}}
\ No newline at end of file
{"file":"success.png","frames":{
"1":{"x":103,"y":230,"w":72,"h":9,"offX":337,"offY":438,"sourceW":750,"sourceH":750},
"2":{"x":0,"y":213,"w":101,"h":30,"offX":329,"offY":396,"sourceW":750,"sourceH":750},
"3":{"x":0,"y":150,"w":102,"h":61,"offX":324,"offY":324,"sourceW":750,"sourceH":750},
"6":{"x":106,"y":0,"w":101,"h":76,"offX":320,"offY":283,"sourceW":750,"sourceH":750},
"7":{"x":108,"y":78,"w":95,"h":78,"offX":323,"offY":275,"sourceW":750,"sourceH":750},
"8":{"x":104,"y":158,"w":88,"h":70,"offX":327,"offY":272,"sourceW":750,"sourceH":750},
"9":{"x":209,"y":0,"w":5,"h":5,"offX":0,"offY":0,"sourceW":750,"sourceH":750},
"5":{"x":0,"y":0,"w":104,"h":76,"offX":320,"offY":289,"sourceW":750,"sourceH":750},
"4":{"x":0,"y":78,"w":106,"h":70,"offX":319,"offY":306,"sourceW":750,"sourceH":750}}}
\ No newline at end of file
...@@ -5,12 +5,8 @@ ...@@ -5,12 +5,8 @@
"name": "rule" "name": "rule"
}, },
{ {
"keys": "basket_top_png,boom_json,bubble_png,candy_json,coin_json,gift_json,glass_png,optionBtn_png,rankBtn_png,recordbtn_png,ruleBtn_png,start_btn_gray_png,start_btn_png,startscenebg_jpg", "keys": "basket_bottom_png,basket_top_png,boom_json,bubble_png,candy_json,coin_json,fail_json,gift_json,glass_png,optionBtn_png,rankBtn_png,recordbtn_png,ruleBtn_png,start_btn_gray_png,start_btn_png,startscenebg_jpg,success_json",
"name": "start" "name": "start"
},
{
"name": "preload",
"keys": "basket_bottom_png"
} }
], ],
"resources": [ "resources": [
...@@ -259,9 +255,21 @@ ...@@ -259,9 +255,21 @@
"name": "basket_top_png" "name": "basket_top_png"
}, },
{ {
"name": "basket_bottom_png", "url": "assets/startScene/basket_bottom.png",
"type": "image", "type": "image",
"url": "assets/startScene/basket_bottom.png" "name": "basket_bottom_png"
},
{
"url": "assets/startScene/success.json",
"type": "sheet",
"name": "success_json",
"subkeys": "1,2,3,4,5,6,7,8,9"
},
{
"url": "assets/startScene/fail.json",
"type": "sheet",
"name": "fail_json",
"subkeys": "1,2,3,4,5,6,7,8"
} }
] ]
} }
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<e:Skin class="StartSkin" width="750" height="1624" xmlns:e="http://ns.egret.com/eui" xmlns:w="http://ns.egret.com/wing"> <e:Skin class="StartSkin" width="750" height="1624" xmlns:e="http://ns.egret.com/eui" xmlns:w="http://ns.egret.com/wing">
<w:Config id="16705cb4eec"/> <w:Config id="16705cb4eec"/>
<e:Image source="startscenebg_jpg" x="0" y="0"/>
<e:Group horizontalCenter="0.5" verticalCenter="547" visible="false"> <e:Group horizontalCenter="0.5" verticalCenter="547" visible="false">
<e:Button id="startBtn" label="" scaleX="1" scaleY="1" anchorOffsetX="152.5" anchorOffsetY="49.5" y="108.21" horizontalCenter="0"> <e:Button id="startBtn" label="" scaleX="1" scaleY="1" anchorOffsetX="152.5" anchorOffsetY="49.5" y="108.21" horizontalCenter="0">
<e:skinName> <e:skinName>
...@@ -32,7 +33,7 @@ ...@@ -32,7 +33,7 @@
</e:Skin> </e:Skin>
</e:skinName> </e:skinName>
</e:Button> </e:Button>
<e:Button id="ruleBtn" label="规则" y="16" scaleX="1" scaleY="1" left="30"> <e:Button id="ruleBtn" label="" y="16" scaleX="1" scaleY="1" left="30">
<e:skinName> <e:skinName>
<e:Skin states="up,down,disabled"> <e:Skin states="up,down,disabled">
<e:Image width="100%" height="100%" source="ruleBtn_png" source.down="ruleBtn_png" source.disabled="ruleBtn_png" /> <e:Image width="100%" height="100%" source="ruleBtn_png" source.down="ruleBtn_png" source.disabled="ruleBtn_png" />
...@@ -40,6 +41,22 @@ ...@@ -40,6 +41,22 @@
</e:Skin> </e:Skin>
</e:skinName> </e:skinName>
</e:Button> </e:Button>
<e:Button id="leftBtn" label="" y="978.3" scaleX="1" scaleY="1" left="79" width="148" height="148" alpha="0">
<e:skinName>
<e:Skin states="up,down,disabled">
<e:Image width="100%" height="100%" source="ruleBtn_png" source.down="ruleBtn_png" source.disabled="ruleBtn_png"/>
<e:Label id="labelDisplay" horizontalCenter="0" verticalCenter="0" size="26"/>
</e:Skin>
</e:skinName>
</e:Button>
<e:Button id="rightBtn" label="" y="978.3" scaleX="1" scaleY="1" width="148" height="148" alpha="0" x="526.09">
<e:skinName>
<e:Skin states="up,down,disabled">
<e:Image width="100%" height="100%" source="ruleBtn_png" source.down="ruleBtn_png" source.disabled="ruleBtn_png"/>
<e:Label id="labelDisplay" horizontalCenter="0" verticalCenter="0" size="26"/>
</e:Skin>
</e:skinName>
</e:Button>
<e:Button id="rankBtn" label="排行榜" y="86.61" scaleX="1" scaleY="1" left="26" visible="false"> <e:Button id="rankBtn" label="排行榜" y="86.61" scaleX="1" scaleY="1" left="26" visible="false">
<e:skinName> <e:skinName>
<e:Skin states="up,down,disabled"> <e:Skin states="up,down,disabled">
...@@ -50,6 +67,6 @@ ...@@ -50,6 +67,6 @@
</e:Button> </e:Button>
<e:Image id="glass" source="glass_png" x="78.5" y="186"/> <e:Image id="glass" source="glass_png" x="78.5" y="186"/>
<e:Image id="basket_bottom" source="basket_bottom_png" x="291.5" y="163.88"/> <e:Image id="basket_bottom" source="basket_bottom_png" x="291.5" y="163.88"/>
<e:Image id="basket_top" source="basket_top_png" x="290.6" y="427.08"/> <e:Image id="basket_top" source="basket_top_png" x="291.6" y="426.08"/>
<e:Image source="bubble_png" x="268" y="1082" visible="false"/> <e:Image source="bubble_png" x="268" y="1082" visible="false"/>
</e:Skin> </e:Skin>
\ No newline at end of file
...@@ -12,6 +12,8 @@ export class MyExmlPlugin extends ExmlPlugin2 implements plugins.Command { ...@@ -12,6 +12,8 @@ export class MyExmlPlugin extends ExmlPlugin2 implements plugins.Command {
'gift.png', 'gift.png',
'boom.png', 'boom.png',
'candy.png', 'candy.png',
'success.png',
'fail.png',
]; ];
if (excludes.indexOf(file.basename) != -1) { if (excludes.indexOf(file.basename) != -1) {
return file; return file;
......
...@@ -63,6 +63,7 @@ export default class MovieClip extends egret.Bitmap { ...@@ -63,6 +63,7 @@ export default class MovieClip extends egret.Bitmap {
this.currentFrame = 0; this.currentFrame = 0;
} else { } else {
this.stop(); this.stop();
this.dispatchEvent(new egret.Event(egret.Event.COMPLETE))
} }
} }
} }
......
import StartSceneBase from "../../libs/new_wx/components/StartSceneBase"; import StartSceneBase from "../../libs/new_wx/components/StartSceneBase";
import DebugRender from "../physics/DebugRender"; import DebugRender from "../physics/DebugRender";
import EgretRender from "../physics/EgretRender"; import EgretRender from "../physics/EgretRender";
import { bubble, bubbleGroup, bubbleMask, award } from "./collisionConfig"; import check from "./check";
import { bubble, bubbleGroup, bubbleMask } from "./collisionConfig";
import createBox from "./createBox"; import createBox from "./createBox";
import createBubblePic from "./createBubblePic"; import createBubblePic from "./createBubblePic";
import createItems from "./createItems"; import createItems from "./createItems";
import random from "./random"; import random from "./random";
import { startStandbyBubblesLeft, stopStandbyBubblesRight, startStandbyBubblesRight, stopStandbyBubblesLeft } from "./standbyBubbles"; import { startStandbyBubblesLeft, startStandbyBubblesRight, stopStandbyBubblesLeft, stopStandbyBubblesRight } from "./standbyBubbles";
import { playScoreAni } from "./playMovieClip";
import createBtns from "./createBtns";
export default class StartScene extends StartSceneBase { export default class StartScene extends StartSceneBase {
_engine: Matter.Engine; _engine: Matter.Engine;
...@@ -69,6 +72,7 @@ export default class StartScene extends StartSceneBase { ...@@ -69,6 +72,7 @@ export default class StartScene extends StartSceneBase {
addForce = false; addForce = false;
stageX = 0; stageX = 0;
stageY = 0;
async runGame() { async runGame() {
createBox(this); createBox(this);
...@@ -77,21 +81,28 @@ export default class StartScene extends StartSceneBase { ...@@ -77,21 +81,28 @@ export default class StartScene extends StartSceneBase {
reslist.map(res => RES.getResAsync(`${res}_json`)) reslist.map(res => RES.getResAsync(`${res}_json`))
); );
RES.getResAsync('success_json');
RES.getResAsync('fail_json');
createItems(this); createItems(this);
Matter.Events.on(this._engine, 'beforeUpdate', () => { Matter.Events.on(this._engine, 'beforeUpdate', () => {
if (!this.addForce) return if (!this.addForce) return
this.addForce = false; this.addForce = false;
const isleft = this.stageX < 375;
const start = isleft ? { x: 208, y: 821 } : { x: 549, y: 821 };
const scale = 2.2; const scale = 2.2;
for (let i = 0; i < 11; i++) { for (let i = 0; i < 15; i++) {
setTimeout(() => { setTimeout(() => {
const r = random(10, 14); const r = random(10, 14);
const bubblePic = createBubblePic(r);//默认球的尺寸100 let bubblePic;
const start = this.stageX < 375 ? { x: 208, y: 821 } : { x: 549, y: 821 }; bubblePic = createBubblePic(r);//默认球的尺寸100
const basex = 0.01; const basex = 0.02;
const fx = this.stageX < 375 ? random(-basex, basex) : random(-basex, basex); const xoffset = 0.007;
const fx = isleft ? random(-basex, basex) : random(-basex, basex);
const padding = 50; const padding = 50;
const startx = random(start.x-padding,start.x+padding); const startx = random(start.x - padding, start.x + padding);
if (fx < -xoffset || fx > xoffset) bubblePic = null;
const body = this._egretRender.circle(startx, start.y, r, bubblePic, const body = this._egretRender.circle(startx, start.y, r, bubblePic,
{ {
density: 0.001 * 3, density: 0.001 * 3,
...@@ -102,72 +113,57 @@ export default class StartScene extends StartSceneBase { ...@@ -102,72 +113,57 @@ export default class StartScene extends StartSceneBase {
); );
setTimeout(() => { setTimeout(() => {
this._egretRender.remove(body) this._egretRender.remove(body);
}, 1000); }, 1000);
}, Math.random() * 200); }, Math.random() * 200);
} }
console.log('吹起来'); for (let j = 0; j < 1; j++) {
}); const start = isleft ? { x: 208 + 50, y: 821 + 30 } : { x: 549 - 50, y: 821 + 30 };
const r = random(10, 14);
const body = this._egretRender.circle(start.x, start.y, r, null,
{
density: 0.001 * 3,
restitution: 1,
force: { x: (isleft ? 1 : -1) * 0.02 * 1.7, y: 0 },
collisionFilter: { group: bubbleGroup, category: bubble, mask: bubbleMask }
}
);
this.stage.addEventListener(egret.TouchEvent.TOUCH_TAP, (e: egret.TouchEvent) => { setTimeout(() => {
this.addForce = true; this._egretRender.remove(body);
this.stageX = e.stageX;
if (this.stageX < 375) {
stopStandbyBubblesLeft();
clearTimeout(this._startStandbyBubblesLeft);
this._startStandbyBubblesLeft = setTimeout(() => {
startStandbyBubblesLeft(this._egretRender);
}, 1000);
} else {
stopStandbyBubblesRight();
clearTimeout(this._startStandbyBubblesRight);
this._startStandbyBubblesRight = setTimeout(() => {
startStandbyBubblesRight(this._egretRender);
}, 1000); }, 1000);
} }
}, this);
startStandbyBubblesLeft(this._egretRender); console.log('吹起来');
startStandbyBubblesRight(this._egretRender); });
}
check() { [this['leftBtn'], this['rightBtn']].forEach(btn => {
const center = 382; btn.addEventListener(egret.TouchEvent.TOUCH_TAP, (e: egret.TouchEvent) => {
const paddingX = 50; this.addForce = true;
const ypos = 440; this.stageX = e.stageX;
const h = 40; if (this.stageX < 375) {
// this._egretRender._root.graphics.beginFill(0xff0000, 1); stopStandbyBubblesLeft();
// this._egretRender._root.graphics.drawRect(center - paddingX, ypos, paddingX * 2, h); clearTimeout(this._startStandbyBubblesLeft);
// this._egretRender._root.graphics.endFill(); this._startStandbyBubblesLeft = setTimeout(() => {
startStandbyBubblesLeft(this._egretRender);
const bodies = Matter.Composite.allBodies(this._engine.world); }, 1000);
const isAward = (i: Matter.Body) => { return i.collisionFilter.group == award } } else {
bodies.forEach(i => { stopStandbyBubblesRight();
if (!isAward(i)) return; clearTimeout(this._startStandbyBubblesRight);
if (i['timer']) { this._startStandbyBubblesRight = setTimeout(() => {
const t0 = Date.now() - i['timer']; startStandbyBubblesRight(this._egretRender);
if (t0 > 3000)//3s之内不可再用 }, 1000);
{
delete i['timer'];
console.log('重新可用', Date.now() / 1000)
}
}
const { x, y } = i.position;
const xResult = x > (center - paddingX) && x < (center + paddingX);
const yResult = y > ypos && y < (ypos + h);
if (xResult && yResult && i.velocity.y > 0 && !i['timer']) {
i['timer'] = Date.now();
if (i.label == 'boom') {
console.log('boom');
this._egretRender.remove(i);
}
else {
console.log('不是boom,重用', Date.now() / 1000);
} }
// this.onGetAward(); // playScoreAni(this,-1)
}
}) }, this);
});
createBtns(this);
startStandbyBubblesLeft(this._egretRender);
startStandbyBubblesRight(this._egretRender);
} }
runEngine() { runEngine() {
...@@ -195,7 +191,7 @@ export default class StartScene extends StartSceneBase { ...@@ -195,7 +191,7 @@ export default class StartScene extends StartSceneBase {
// console.log(delta); // console.log(delta);
this._debugRender.run(); this._debugRender.run();
this._egretRender.run(); this._egretRender.run();
this.check(); check(this);
return false; return false;
} }
......
import { award } from "./collisionConfig";
import StartScene from "./StartScene";
import { playBoom, playSuccess, playScoreAni } from "./playMovieClip";
import vibrate from "./vibrate";
const check = (_this: StartScene) => {
const center = 382;
const paddingX = 50;
const ypos = 440;
const h = 40;
// _this._egretRender._root.graphics.beginFill(0xff0000, 1);
// _this._egretRender._root.graphics.drawRect(center - paddingX, ypos, paddingX * 2, h);
// _this._egretRender._root.graphics.endFill();
const bodies = Matter.Composite.allBodies(_this._engine.world);
const isAward = (i: Matter.Body) => { return i.collisionFilter.group == award }
bodies.forEach(i => {
if (!isAward(i)) return;
if (i['timer']) {
const t0 = Date.now() - i['timer'];
if (t0 > 3000)//3s之内不可再用
{
delete i['timer'];
console.log('重新可用', Date.now() / 1000)
}
}
const { x, y } = i.position;
const xResult = x > (center - paddingX) && x < (center + paddingX);
const yResult = y > ypos && y < (ypos + h);
if (xResult && yResult && i.velocity.y > 0 && !i['timer']) {
i['timer'] = Date.now();
if (i.label == 'boom') {
console.log('boom');
_this._egretRender.remove(i);
vibrate(_this, 2);
playBoom(_this);
playScoreAni(_this, -1);
}
else {
console.log('不是boom,重用', Date.now() / 1000);
playScoreAni(_this, 1)
playSuccess(_this);
}
// _this.onGetAward();
}
})
}
export default check
\ No newline at end of file
...@@ -18,11 +18,14 @@ const createBox = (_this: StartScene) => { ...@@ -18,11 +18,14 @@ const createBox = (_this: StartScene) => {
const basketbody2 = Matter.Bodies.fromVertices(449, 452, [basketpath2], { isStatic: true, collisionFilter: { group: basket, category: basket, mask: basketMask } }, true); const basketbody2 = Matter.Bodies.fromVertices(449, 452, [basketpath2], { isStatic: true, collisionFilter: { group: basket, category: basket, mask: basketMask } }, true);
Matter.World.add(_this._engine.world, basketbody2); Matter.World.add(_this._engine.world, basketbody2);
//153 823
const w = 100; const w = 100;
const h = 50; const h = 50;
const rect = _this._egretRender.rectangle(153 + w / 2, 833 + h / 2, w, h, null, { isStatic: true, collisionFilter: { group: wall, category: wall, mask: wallMask } }); const rect = _this._egretRender.rectangle(153 + w / 2, 833 + h / 2, w, h, null, { isStatic: true, collisionFilter: { group: wall, category: wall, mask: wallMask } });
const rect2 = _this._egretRender.rectangle(553 - 10 - 30 - 5 + w / 2, 833 + h / 2, w, h, null, { isStatic: true, collisionFilter: { group: wall, category: wall, mask: wallMask } }); const rect2 = _this._egretRender.rectangle(553 - 10 - 30 - 5 + w / 2, 833 + h / 2, w, h, null, { isStatic: true, collisionFilter: { group: wall, category: wall, mask: wallMask } });
const w2 = 300;
const h2 = 10;
const rect3 = _this._egretRender.rectangle(375, 873+h2/2 , w2, h2, null, { isStatic: true, collisionFilter: { group: wall, category: wall, mask: wallMask } });
} }
export default createBox export default createBox
\ No newline at end of file
import StartScene from "./StartScene";
export default (that: StartScene) => {
const createShape = () => {
const shape = new egret.Shape();
shape.graphics.beginFill(0, .6);
shape.graphics.drawCircle(0, 0, that['leftBtn'].width / 2);
shape.graphics.endFill();
shape.anchorOffsetX = -that['leftBtn'].width / 2;
shape.anchorOffsetY = -that['leftBtn'].width / 2;
return shape
}
[that['leftBtn'], that['rightBtn']].forEach(btn => {
btn.addEventListener(egret.TouchEvent.TOUCH_BEGIN, (e: egret.TouchEvent) => {
const btn = e.currentTarget;
const shape = btn.maskShape;
egret.Tween.removeTweens(shape);
egret.Tween.get(shape).to({ alpha: 0 }, 200);
}, that);
});
[that['leftBtn'], that['rightBtn']].forEach(btn => {
btn.addEventListener(egret.TouchEvent.TOUCH_END, (e: egret.TouchEvent) => {
const btn = e.currentTarget;
const shape = btn.maskShape;
egret.Tween.removeTweens(shape);
egret.Tween.get(shape).to({ alpha: 1 }, 200);
}, that);
});
[that['leftBtn'], that['rightBtn']].forEach(btn => {
btn.addEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE, (e: egret.TouchEvent) => {
const btn = e.currentTarget;
const shape = btn.maskShape;
egret.Tween.removeTweens(shape);
egret.Tween.get(shape).to({ alpha: 1 }, 200);
}, that);
});
// this['rightBtn'];
const shapeLeft = createShape();
that.addChild(shapeLeft);
shapeLeft.x = that['leftBtn'].x;
shapeLeft.y = that['leftBtn'].y;
that['leftBtn'].maskShape = shapeLeft;
const shapeR = createShape();
that.addChild(shapeR);
shapeR.x = that['rightBtn'].x;
shapeR.y = that['rightBtn'].y;
that['rightBtn'].maskShape = shapeR;
}
...@@ -5,7 +5,7 @@ import { award, awardMask } from "./collisionConfig"; ...@@ -5,7 +5,7 @@ import { award, awardMask } from "./collisionConfig";
export default (_this: StartScene) => { export default (_this: StartScene) => {
let count = 0; let count = 0;
const coinsFall = setInterval(() => { const coinsFall = setInterval(() => {
if (count < 15) { if (count < 12) {
let scale; let scale;
scale = 0.7 + Math.random() * 0.3; scale = 0.7 + Math.random() * 0.3;
const baseItem = createItem(scale); const baseItem = createItem(scale);
...@@ -15,6 +15,7 @@ export default (_this: StartScene) => { ...@@ -15,6 +15,7 @@ export default (_this: StartScene) => {
//刚体和贴图尺寸比为1:1.12 //刚体和贴图尺寸比为1:1.12
_this._egretRender.circle(375 + Math.random() * 200 - 100, 400 + 200 + 100, 100 * scale / 2 / 1.12, baseItem, _this._egretRender.circle(375 + Math.random() * 200 - 100, 400 + 200 + 100, 100 * scale / 2 / 1.12, baseItem,
{ {
frictionAir:0,
collisionFilter: { group: award, category: award, mask: awardMask }, collisionFilter: { group: award, category: award, mask: awardMask },
angle: angle, angle: angle,
label: baseItem.type label: baseItem.type
......
import wait from "../../libs/new_tc/wait";
import MovieClip from "../physics/movieclip/MovieClip";
const playMovieClip = async (parent: egret.DisplayObjectContainer, key, frames, frameInterval = 5) => {
return new Promise(async (r) => {
let texture: egret.SpriteSheet;
texture = RES.getRes(key);
if (texture) {
await createMc(parent, texture, frames, frameInterval);
r(1);
}
else {
RES.getResAsync(key);
wait(300).then(async () => {
texture = RES.getRes(key);
if (texture) {
await createMc(parent, texture, frames, frameInterval);
r(1);
} else
r(0);
})
}
});
}
const createMc = (parent: egret.DisplayObjectContainer, spritesheet: egret.SpriteSheet, frames: any[], frameInterval = 5) => {
return new Promise((r) => {
const movieclip = new MovieClip({
spritesheet: spritesheet,
frameInterval: frameInterval,
frames: frames,
position: [0, 0],
scale: 1,
anchor: [0, 0],
loop: false
});
parent.addChild(movieclip);
movieclip.once(egret.Event.COMPLETE, () => {
parent.removeChild(movieclip);
r(1)
}, this)
})
}
export const playSuccess = (parent) => {
return playMovieClip(parent, 'success_json', ['1', '2', '3', '4', '5', '6', '7', '8', '9'], 5);
}
export const playBoom = (parent) => {
return playMovieClip(parent, 'fail_json', ['1', '2', '3', '4', '5', '6', '7', '8'], 5);
}
export const playScoreAni = (parent, score: number) => {
const txt = createText(score);
txt.scaleX = txt.scaleY = 0;
parent.addChild(txt);
txt.x = 375 + 100;
txt.y = 375;
txt.anchorOffsetX = txt.textWidth / 2;
txt.anchorOffsetY = txt.textHeight / 2;
egret.Tween.get(txt).to({ scaleX: 1, scaleY: 1 }, 300, egret.Ease.getBackOut(6)).wait(500)
.to({ y: txt.y - 100, alpha: 0 }, 700).call(() => {
})
}
const createText = (score: number) => {
const txt = new egret.TextField();
txt.size = 40;
txt.bold = true;
const prefix = score > 0 ? '+' : '';
txt.text = prefix + score;
txt.textColor = score > 0 ? 0x00ff00 : 0xff0000;
return txt;
}
\ No newline at end of file
export default (view: egret.DisplayObject,count=2,strength=10) => {
return new Promise((r) => {
const pos = [
{ x: strength, y: 0 },
{ x: 0, y: -strength },
{ x: -strength, y: 0 },
{ x: 0, y: strength },
{ x: 0, y: 0 },
];
let list = [];
for (let i = 0; i < count; i++) {
list = list.concat(pos);
}
const x0 = view.x;
const y0 = view.y;
let counter = list.length;
for (let i = 0; i < list.length; i++) {
const element = list[i];
setTimeout(() => {
view.x = element.x + x0;
view.y = element.y + y0;
counter--;
if (counter == 0) {
view.x = x0;
view.y = y0;
r();
};
}, 1000 / 60 * i);
}
});
}
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