Commit e506c4d0 authored by Master Q's avatar Master Q

游戏 第一版完善

parent 779887cb
......@@ -68,7 +68,11 @@
var canvas = document.getElementById("canvas");
canvas.width = document.body.clientWidth * (window.devicePixelRatio || 1)
canvas.height = document.body.clientHeight * (window.devicePixelRatio || 1)
var main = new Main(canvas);
var main = new Main(canvas, {
isNewGuy: true,
debug: true,
musicSwitchDefault: false
});
var mouseEvent = main.stage.onMouseEvent.bind(main.stage);
canvas.addEventListener("touchstart", mouseEvent, false);
canvas.addEventListener('touchmove', mouseEvent, false);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"success": true
}
\ No newline at end of file
......@@ -11,7 +11,6 @@ export class GPool {
*/
public static takeOut<T>(name: string): T {
if (this.pool[name] && this.pool[name].length) {
// console.log('从对象池中去')
return this.pool[name].shift();
}
return null;
......
{
"groups": [
{
"keys": "GameOverPanelBack.png,atomphere.png,back.png,cancel-btn.png,confirm-btn.png",
"name": "GameOverPanel"
"keys": "Guide1.png,Guide2.png,Guide3.png,bucket_GE.png,gamer-protect.png,hpBoard-back.png,hpBoard-hp.png,left_m.png,music-off.png,music-on.png,powerBallShadow.png,powerProgress-back.png,powerProgress-logo.png,powerProgress-p.png,red_obstacle.png,red_obstacle0.png,right_m.png,scene-back.jpg,score_0.png,score_1.png,score_2.png,score_3.png,score_4.png,score_5.png,score_6.png,score_7.png,score_8.png,score_9.png,score_m.png,water_GE.png,yellow_obstacle.png,yellow_obstacle0.png",
"name": "LevonoGameScene"
},
{
"keys": "GameSceneBack.png,PrizeCard.png,Rabbit.png,SnowBall.png,Star.png,countDown-back.png,finalgiftbox-disabled.png,finalgiftbox.png,giftbox-disabled.png,giftbox.png,goal0.png,guide1.png,progress-back.png,progress-point.png,radish-tips.png,score+.png,score-back.png,score0.png,score1.png,score2.png,score3.png,score4.png,score5.png,score6.png,score7.png,score8.png,score9.png,雪人.svga",
"name": "GameScene"
"keys": "countDown.svga,mountain.svga,normalGamer.svga,powerBall.svga,speedShow.svga,speedUpGamer.svga,tree.svga,障碍物.svga,障碍物2.svga",
"name": "LevonoSvga"
},
{
"keys": "index-scene-back.png,index_back_btn.png,index_rule_btn.png,lucky-ani.png,start-btn.png",
"name": "IndexScene"
"keys": "0164ce9f97c1351ee408f2bb47f40804.png,28006e5a01c626254a11e2e81a546c43.png,3370e35def80441da5a39f0645d88706.png,41c1d044db50f24c6a0487c298f75050.png,498ca4d3f629a6d00ed906b4d5e5e821.png,52a9792562c9f4ed30ace0155c711793.png,5d9932758c0ffdc7ab90c5f79d82fe5e.png,60051d951deade9bbb8223c4ba7e0f4a.png,6a6bd5e469cd0d59fb9e439f81217f3d.png,6dfac66424f05bb4084d963e4a9d09f0.png,78b3a03e48d1068c2a3de2e940775cfc.png,8d31690f54217e3196991204cae42a11.png,9714def3226819a6055515694f08ab94.png,9f0f64188bd84e6d239e36019b33bb40.png,a1c33bb4ac6bc12e368e4956e530e874.png,a33f4734da805886b130702b082982a9.png,b0e41055f57df4dcf4ecfccbc656a63f.png,b966bc1ca2b9a34764a2437c4215e8c9.png,c6e16847929c5da97d053d17120a0d68.png,cb50e329f0b82c3f0ce655a0f8be972b.png,d3c4b07c8a7de09c862417a6342bdeff.png,e8bf00e43a221c77ed7daf919f402ce1.png,eee4d4b331764e60a6570a8874553bb9.png,f0d16f3820d2b525a8a7a0c8f72cd794.png",
"name": "banner1"
},
{
"keys": "024280fed19ab27076c5603959501914.png,05f565f4e9257b665a779bf070daec1c.png,1b6e94c28a073e8ab266a8c4a813378e.png,1ccfc67ec7056d6d83dcdce617014657.png,2d73d2d9da9b09fecfef6805a373ab85.png,30d0615c544780879a52287e6e0d7e28.png,40868c37b8e8ae5f4382d2a1f59bac3a.png,412c0c261d3b89928e6f0b92f1a250b2.png,41bebcdee778b238ab274411a3f00e3c.png,6f807cbbf5e4684a193fdd5487ce7252.png,71c8647355e187f452c7a22148b1a2b7.png,77c9ccf6da03788bdd627e1241de1a44.png,7aa0605d9803d2f0995411738bd28cdb.png,7cda9a80d6188909df0db43e457dbfb1.png,7f16355a569cc7eb9969b981b4634ff5.png,90cea1bb2c83fd8df25c1c3541da0b01.png,9c88ef64a01ca17439d550c60f168eb5.png,a54f77095632eeb1a66a157dba068741.png,b7344d455c9e425b3594dc984c45e2bd.png,b81f9dd63a41b0c87a7790043c62a95c.png,c3007d8328a0639c5eceb80892615f38.png,d02fd69a469219be644bc49d4a31d59e.png,d451b9786349b1e706975daf4d8e2f85.png,f764373c1caa0d42634ce916661160d5.png",
"name": "banner2"
},
{
"keys": "Radish.png,comCloseBtn.png,com_light.png,com_light2.png,gn0.png,gn1.png,gn2.png,gn3.png,gn4.png,gn5.png,gn6.png,gn7.png,gn8.png,gn9.png,gnm.png,index_sound_off.png,index_sound_on.png,toastBg.png,waitingBg.png,waitingRot.png",
......
......@@ -9,8 +9,8 @@ import { destroyTbNetData, sendTbNet, TbNetName } from "./TaoBaoNet";
import { SkinJson } from "./SkinJson";
import { G_EVENT } from "./common/G_EVENT";
import { Tools } from "./Tools";
import IndexScene from './scenes/IndexScene';
import { GameOverPanel } from "./components/GameOverPanel";
import { LevonoGameScene } from "./scenes/LevonoGameScene/LevonoGameScene";
import { GameDiffConfig } from "./scenes/LevonoGameScene/GameEle";
/**
* 全局事件,为了和小程序交互
......@@ -178,17 +178,15 @@ export class Main {
// return;
// }
await Promise.all([
sendTbNet(TbNetName.doIndex)
])
// vtodo 是否是新手
changeScene(IndexScene);
// showPanel(GameOverPanel, {
// "score": 11,
// "maxScore": 11,
// "rewardCredits": 11
// })
// await Promise.all([
// sendTbNet(TbNetName.doIndex)
// ])
// 初始化
GameDiffConfig.initGameDiff(Tools.PAGE.GameConfig)
changeScene(LevonoGameScene, {
...Tools.PAGE
});
}
}
......
export const ResJson = {
"groups": [
{
"keys": "GameOverPanelBack.png,atomphere.png,back.png,cancel-btn.png,confirm-btn.png",
"name": "GameOverPanel",
"atlas": {
"back.png": {
"x": 2,
"y": 2,
"w": 750,
"h": 865,
"ox": 0,
"oy": 0,
"sw": 750,
"sh": 865,
"ro": false
},
"atomphere.png": {
"x": 754,
"y": 2,
"w": 750,
"h": 791,
"ox": 0,
"oy": 0,
"sw": 750,
"sh": 791,
"ro": false
},
"GameOverPanelBack.png": {
"x": 2,
"y": 869,
"w": 616,
"h": 599,
"ox": 0,
"oy": 0,
"sw": 616,
"sh": 599,
"ro": false
},
"cancel-btn.png": {
"x": 620,
"y": 869,
"w": 258,
"h": 95,
"ox": 0,
"oy": 0,
"sw": 258,
"sh": 95,
"ro": true
},
"confirm-btn.png": {
"x": 620,
"y": 1129,
"w": 258,
"h": 95,
"ox": 0,
"oy": 0,
"sw": 258,
"sh": 95,
"ro": true
}
}
"keys": "Guide1.png,Guide2.png,Guide3.png,bucket_GE.png,gamer-protect.png,hpBoard-back.png,hpBoard-hp.png,left_m.png,music-off.png,music-on.png,powerBallShadow.png,powerProgress-back.png,powerProgress-logo.png,powerProgress-p.png,red_obstacle.png,red_obstacle0.png,right_m.png,scene-back.jpg,score_0.png,score_1.png,score_2.png,score_3.png,score_4.png,score_5.png,score_6.png,score_7.png,score_8.png,score_9.png,score_m.png,water_GE.png,yellow_obstacle.png,yellow_obstacle0.png",
"name": "LevonoGameScene"
},
{
"keys": "GameSceneBack.png,PrizeCard.png,Rabbit.png,SnowBall.png,Star.png,countDown-back.png,finalgiftbox-disabled.png,finalgiftbox.png,giftbox-disabled.png,giftbox.png,goal0.png,guide1.png,progress-back.png,progress-point.png,radish-tips.png,score+.png,score-back.png,score0.png,score1.png,score2.png,score3.png,score4.png,score5.png,score6.png,score7.png,score8.png,score9.png,雪人.svga",
"name": "GameScene",
"atlas": {
"GameSceneBack.png": {
"x": 2,
"y": 2,
"w": 750,
"h": 1624,
"ox": 0,
"oy": 0,
"sw": 750,
"sh": 1624,
"ro": false
},
"guide1.png": {
"x": 754,
"y": 2,
"w": 750,
"h": 1624,
"ox": 0,
"oy": 0,
"sw": 750,
"sh": 1624,
"ro": false
},
"radish-tips.png": {
"x": 1506,
"y": 2,
"w": 592,
"h": 186,
"ox": 0,
"oy": 0,
"sw": 592,
"sh": 186,
"ro": true
},
"progress-back.png": {
"x": 1506,
"y": 596,
"w": 459,
"h": 130,
"ox": 0,
"oy": 0,
"sw": 459,
"sh": 130,
"ro": true
},
"Rabbit.png": {
"x": 2,
"y": 1628,
"w": 228,
"h": 315,
"ox": 0,
"oy": 0,
"sw": 228,
"sh": 315,
"ro": true
},
"score-back.png": {
"x": 1506,
"y": 1057,
"w": 240,
"h": 55,
"ox": 0,
"oy": 0,
"sw": 240,
"sh": 55,
"ro": true
},
"SnowBall.png": {
"x": 1506,
"y": 1299,
"w": 176,
"h": 209,
"ox": 0,
"oy": 0,
"sw": 176,
"sh": 209,
"ro": false
},
"PrizeCard.png": {
"x": 1506,
"y": 1510,
"w": 185,
"h": 189,
"ox": 0,
"oy": 0,
"sw": 185,
"sh": 189,
"ro": false
},
"Star.png": {
"x": 319,
"y": 1701,
"w": 138,
"h": 158,
"ox": 0,
"oy": 0,
"sw": 138,
"sh": 158,
"ro": true
},
"countDown-back.png": {
"x": 1563,
"y": 1057,
"w": 80,
"h": 93,
"ox": 0,
"oy": 0,
"sw": 80,
"sh": 93,
"ro": true
},
"goal0.png": {
"x": 319,
"y": 1628,
"w": 64,
"h": 55,
"ox": 0,
"oy": 0,
"sw": 64,
"sh": 55,
"ro": true
},
"finalgiftbox-disabled.png": {
"x": 1638,
"y": 596,
"w": 49,
"h": 49,
"ox": 0,
"oy": 0,
"sw": 49,
"sh": 49,
"ro": false
},
"finalgiftbox.png": {
"x": 1638,
"y": 647,
"w": 49,
"h": 49,
"ox": 0,
"oy": 0,
"sw": 49,
"sh": 49,
"ro": false
},
"score0.png": {
"x": 1658,
"y": 698,
"w": 33,
"h": 46,
"ox": 0,
"oy": 0,
"sw": 33,
"sh": 46,
"ro": false
},
"score3.png": {
"x": 1658,
"y": 746,
"w": 33,
"h": 46,
"ox": 0,
"oy": 0,
"sw": 33,
"sh": 46,
"ro": false
},
"score6.png": {
"x": 1658,
"y": 794,
"w": 31,
"h": 46,
"ox": 0,
"oy": 0,
"sw": 31,
"sh": 46,
"ro": false
},
"score8.png": {
"x": 1658,
"y": 842,
"w": 32,
"h": 46,
"ox": 0,
"oy": 0,
"sw": 32,
"sh": 46,
"ro": false
},
"score9.png": {
"x": 1658,
"y": 890,
"w": 32,
"h": 46,
"ox": 0,
"oy": 0,
"sw": 32,
"sh": 46,
"ro": false
},
"score2.png": {
"x": 1658,
"y": 938,
"w": 32,
"h": 45,
"ox": 0,
"oy": 0,
"sw": 32,
"sh": 45,
"ro": false
},
"score5.png": {
"x": 1658,
"y": 985,
"w": 33,
"h": 45,
"ox": 0,
"oy": 0,
"sw": 33,
"sh": 45,
"ro": false
},
"score1.png": {
"x": 1658,
"y": 1032,
"w": 30,
"h": 44,
"ox": 0,
"oy": 0,
"sw": 30,
"sh": 44,
"ro": false
},
"score4.png": {
"x": 376,
"y": 1628,
"w": 35,
"h": 44,
"ox": 0,
"oy": 0,
"sw": 35,
"sh": 44,
"ro": false
},
"score7.png": {
"x": 1658,
"y": 1078,
"w": 32,
"h": 44,
"ox": 0,
"oy": 0,
"sw": 32,
"sh": 44,
"ro": false
},
"giftbox-disabled.png": {
"x": 413,
"y": 1628,
"w": 37,
"h": 43,
"ox": 0,
"oy": 0,
"sw": 37,
"sh": 43,
"ro": false
},
"giftbox.png": {
"x": 452,
"y": 1628,
"w": 37,
"h": 43,
"ox": 0,
"oy": 0,
"sw": 37,
"sh": 43,
"ro": false
},
"score+.png": {
"x": 1658,
"y": 1124,
"w": 34,
"h": 34,
"ox": 0,
"oy": 0,
"sw": 34,
"sh": 34,
"ro": false
},
"progress-point.png": {
"x": 376,
"y": 1674,
"w": 20,
"h": 20,
"ox": 0,
"oy": 0,
"sw": 20,
"sh": 20,
"ro": false
}
}
"keys": "countDown.svga,mountain.svga,normalGamer.svga,powerBall.svga,speedShow.svga,speedUpGamer.svga,tree.svga,障碍物.svga,障碍物2.svga",
"name": "LevonoSvga"
},
{
"keys": "index-scene-back.png,index_back_btn.png,index_rule_btn.png,lucky-ani.png,start-btn.png",
"name": "IndexScene",
"atlas": {
"index-scene-back.png": {
"x": 2,
"y": 2,
"w": 750,
"h": 1624,
"ox": 0,
"oy": 0,
"sw": 750,
"sh": 1624,
"ro": false
},
"lucky-ani.png": {
"x": 754,
"y": 2,
"w": 751,
"h": 761,
"ox": 0,
"oy": 0,
"sw": 750,
"sh": 952,
"ro": false
"keys": "0164ce9f97c1351ee408f2bb47f40804.png,28006e5a01c626254a11e2e81a546c43.png,3370e35def80441da5a39f0645d88706.png,41c1d044db50f24c6a0487c298f75050.png,498ca4d3f629a6d00ed906b4d5e5e821.png,52a9792562c9f4ed30ace0155c711793.png,5d9932758c0ffdc7ab90c5f79d82fe5e.png,60051d951deade9bbb8223c4ba7e0f4a.png,6a6bd5e469cd0d59fb9e439f81217f3d.png,6dfac66424f05bb4084d963e4a9d09f0.png,78b3a03e48d1068c2a3de2e940775cfc.png,8d31690f54217e3196991204cae42a11.png,9714def3226819a6055515694f08ab94.png,9f0f64188bd84e6d239e36019b33bb40.png,a1c33bb4ac6bc12e368e4956e530e874.png,a33f4734da805886b130702b082982a9.png,b0e41055f57df4dcf4ecfccbc656a63f.png,b966bc1ca2b9a34764a2437c4215e8c9.png,c6e16847929c5da97d053d17120a0d68.png,cb50e329f0b82c3f0ce655a0f8be972b.png,d3c4b07c8a7de09c862417a6342bdeff.png,e8bf00e43a221c77ed7daf919f402ce1.png,eee4d4b331764e60a6570a8874553bb9.png,f0d16f3820d2b525a8a7a0c8f72cd794.png",
"name": "banner1"
},
"start-btn.png": {
"x": 754,
"y": 765,
"w": 454,
"h": 118,
"ox": 0,
"oy": 0,
"sw": 454,
"sh": 118,
"ro": false
},
"index_back_btn.png": {
"x": 1210,
"y": 765,
"w": 131,
"h": 53,
"ox": 0,
"oy": 0,
"sw": 131,
"sh": 53,
"ro": false
},
"index_rule_btn.png": {
"x": 1343,
"y": 765,
"w": 130,
"h": 53,
"ox": 0,
"oy": 0,
"sw": 130,
"sh": 53,
"ro": false
}
}
{
"keys": "024280fed19ab27076c5603959501914.png,05f565f4e9257b665a779bf070daec1c.png,1b6e94c28a073e8ab266a8c4a813378e.png,1ccfc67ec7056d6d83dcdce617014657.png,2d73d2d9da9b09fecfef6805a373ab85.png,30d0615c544780879a52287e6e0d7e28.png,40868c37b8e8ae5f4382d2a1f59bac3a.png,412c0c261d3b89928e6f0b92f1a250b2.png,41bebcdee778b238ab274411a3f00e3c.png,6f807cbbf5e4684a193fdd5487ce7252.png,71c8647355e187f452c7a22148b1a2b7.png,77c9ccf6da03788bdd627e1241de1a44.png,7aa0605d9803d2f0995411738bd28cdb.png,7cda9a80d6188909df0db43e457dbfb1.png,7f16355a569cc7eb9969b981b4634ff5.png,90cea1bb2c83fd8df25c1c3541da0b01.png,9c88ef64a01ca17439d550c60f168eb5.png,a54f77095632eeb1a66a157dba068741.png,b7344d455c9e425b3594dc984c45e2bd.png,b81f9dd63a41b0c87a7790043c62a95c.png,c3007d8328a0639c5eceb80892615f38.png,d02fd69a469219be644bc49d4a31d59e.png,d451b9786349b1e706975daf4d8e2f85.png,f764373c1caa0d42634ce916661160d5.png",
"name": "banner2"
},
{
"keys": "Radish.png,comCloseBtn.png,com_light.png,com_light2.png,gn0.png,gn1.png,gn2.png,gn3.png,gn4.png,gn5.png,gn6.png,gn7.png,gn8.png,gn9.png,gnm.png,index_sound_off.png,index_sound_on.png,toastBg.png,waitingBg.png,waitingRot.png",
"name": "common",
"atlas": {
"com_light.png": {
"x": 2,
"y": 2,
"w": 746,
"h": 756,
"ox": 0,
"oy": 0,
"sw": 746,
"sh": 756,
"ro": false
},
"toastBg.png": {
"x": 750,
"y": 2,
"w": 460,
"h": 130,
"ox": 0,
"oy": 0,
"sw": 460,
"sh": 130,
"ro": true
},
"waitingBg.png": {
"x": 2,
"y": 760,
"w": 160,
"h": 180,
"ox": 0,
"oy": 0,
"sw": 160,
"sh": 180,
"ro": true
},
"com_light2.png": {
"x": 184,
"y": 760,
"w": 138,
"h": 140,
"ox": 0,
"oy": 0,
"sw": 138,
"sh": 140,
"ro": false
},
"Radish.png": {
"x": 750,
"y": 464,
"w": 63,
"h": 85,
"ox": 0,
"oy": 0,
"sw": 63,
"sh": 85,
"ro": true
},
"comCloseBtn.png": {
"x": 750,
"y": 529,
"w": 72,
"h": 72,
"ox": 0,
"oy": 0,
"sw": 72,
"sh": 72,
"ro": false
},
"index_sound_off.png": {
"x": 750,
"y": 603,
"w": 62,
"h": 62,
"ox": 0,
"oy": 0,
"sw": 62,
"sh": 62,
"ro": false
},
"index_sound_on.png": {
"x": 814,
"y": 603,
"w": 62,
"h": 62,
"ox": 0,
"oy": 0,
"sw": 62,
"sh": 62,
"ro": false
},
"waitingRot.png": {
"x": 824,
"y": 529,
"w": 56,
"h": 56,
"ox": 0,
"oy": 0,
"sw": 56,
"sh": 56,
"ro": false
},
"gn0.png": {
"x": 184,
"y": 902,
"w": 18,
"h": 24,
"ox": 0,
"oy": 0,
"sw": 18,
"sh": 24,
"ro": true
},
"gn1.png": {
"x": 210,
"y": 902,
"w": 17,
"h": 24,
"ox": 0,
"oy": 0,
"sw": 17,
"sh": 24,
"ro": true
},
"gn2.png": {
"x": 236,
"y": 902,
"w": 18,
"h": 24,
"ox": 0,
"oy": 0,
"sw": 18,
"sh": 24,
"ro": true
},
"gn3.png": {
"x": 262,
"y": 902,
"w": 17,
"h": 24,
"ox": 0,
"oy": 0,
"sw": 17,
"sh": 24,
"ro": true
},
"gn4.png": {
"x": 837,
"y": 464,
"w": 19,
"h": 24,
"ox": 0,
"oy": 0,
"sw": 19,
"sh": 24,
"ro": true
},
"gn5.png": {
"x": 288,
"y": 902,
"w": 18,
"h": 24,
"ox": 0,
"oy": 0,
"sw": 18,
"sh": 24,
"ro": true
},
"gn6.png": {
"x": 314,
"y": 902,
"w": 18,
"h": 24,
"ox": 0,
"oy": 0,
"sw": 18,
"sh": 24,
"ro": true
},
"gn7.png": {
"x": 837,
"y": 485,
"w": 18,
"h": 24,
"ox": 0,
"oy": 0,
"sw": 18,
"sh": 24,
"ro": false
},
"gn8.png": {
"x": 857,
"y": 485,
"w": 18,
"h": 24,
"ox": 0,
"oy": 0,
"sw": 18,
"sh": 24,
"ro": false
},
"gn9.png": {
"x": 750,
"y": 667,
"w": 18,
"h": 24,
"ox": 0,
"oy": 0,
"sw": 18,
"sh": 24,
"ro": true
},
"gnm.png": {
"x": 863,
"y": 464,
"w": 10,
"h": 19,
"ox": 0,
"oy": 0,
"sw": 10,
"sh": 19,
"ro": false
}
}
"name": "common"
},
{
"keys": "左右建筑.svga,游戏倒计时 2.svga,游戏兔子.svga,游戏道路循环.svga,获奖弹窗.svga,道具光环.svga,首页兔子.svga,首页背景动画.svga",
"name": "svga"
}
],
"path": "https://yun.duiba.com.cn/db_games/activity/template/1640697401/resource/"
"path": "./resource/"
}
\ No newline at end of file
......@@ -19,9 +19,9 @@ export enum TbNetName {
receiveInvitePrize = "xunzai.receiveInvitePrize",
startGame = "yoga.startGame",
startGame = "levono.startGame",
submitGame = "yoga.submitGame",
submitGame = "levono.submitGame",
drawLotteryPrize = "yoga.drawLotteryPrize",
......
......@@ -38,7 +38,15 @@ export const myApp:AppType = getApp()
*/
export class Tools {
public static PAGE;
public static PAGE: {
isNewGuy: boolean,
debug: boolean,
GameConfig: Array<{
proportion: Array<number>
mileage: number
}>,
musicSwitchDefault: boolean
};
/**
* 缓存key
......
......@@ -167,4 +167,11 @@ export default class UI {
parent && parent.addChild(lottie);
return lottie;
}
public static MoiveClip(parent: Container, name: string, x: number = 0, y: number = 0) {
const mc = new FYGE.MovieClip(RES.getRes(name))
mc.position.set(x, y)
parent.addChild(mc)
return mc
}
}
type direct = 'right' | 'bottom' | 'top'
/**
* 传入文案和进度条图片
* 进度条图片位移,固定遮罩
......@@ -8,9 +10,12 @@ export class ProgressBarS {
private progressTxt: FYGE.TextField;
private maxLength: number;
private oriX: number
private oriY: number
private dire: direct
constructor(upImage: FYGE.Sprite, txt?: FYGE.TextField) {
this.maxLength = upImage.width;//最大长度,直接取图片宽度
constructor(upImage: FYGE.Sprite, txt?: FYGE.TextField, dire?: direct) {
this.dire = dire
this.maxLength = dire === 'right' ? upImage.width : upImage.height;//最大长度,直接取图片宽度
this.upImage = upImage;
......@@ -18,6 +23,7 @@ export class ProgressBarS {
this.oriX = upImage.x;
this.oriY = upImage.y
var delta = 0
//传入的也可能是帧动画,这样原点就有问题了
if (upImage instanceof FYGE.FrameAni) delta = 0.5
......@@ -51,6 +57,13 @@ export class ProgressBarS {
if (v > 1) v = 1;
this._value = v;
if (this.progressTxt) this.progressTxt.text = ((v * 100) >> 0) + "%";
this.upImage.x = this.oriX - (1 - this._value) * this.maxLength
let xory = this.dire === 'right' ? 'x' : 'y'
let o = this.dire === 'right' ? this.oriX : this.oriY
if (this.dire === 'top') {
this.upImage[xory] = o + (1 - this._value) * this.maxLength
} else {
this.upImage[xory] = o - (1 - this._value) * this.maxLength
}
}
}
......@@ -2,7 +2,6 @@ import { changeScene } from './../../module/ctrls/index';
import { RES } from "../../module/RES";
import { Panel } from "../../module/views/Panel";
import UI from "../UI";
import IndexScene from '../scenes/IndexScene';
import { LOG_TYPE, sendLog } from '../WebNet';
interface GameOverPanelInfer {
......@@ -40,7 +39,6 @@ export class GameOverPanel extends Panel {
UI.Btn(RoleContainer, 'cancel-btn.png', function() {
sendLog(LOG_TYPE.CLICK, 75)
this.hidePanel()
changeScene(IndexScene)
}, this, 40, 430)
UI.Btn(RoleContainer, 'confirm-btn.png', async function() {
......
export const banner1 = {
"fr": 30,
"ip": 0,
"op": 24,
"w": 325,
"h": 381,
"nm": "左牌子222222",
"layers": [
{
"ind": 1,
"ty": 2,
"nm": "左牌子 合成 2_00016.png",
"refId": "9714def3226819a6055515694f08ab94",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
156.5,
0
]
},
"a": {
"k": [
162.5,
155.5,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 0,
"op": 1
},
{
"ind": 2,
"ty": 2,
"nm": "左牌子 合成 2_00017.png",
"refId": "78b3a03e48d1068c2a3de2e940775cfc",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
156.5,
0
]
},
"a": {
"k": [
162.5,
155.5,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 1,
"op": 2
},
{
"ind": 3,
"ty": 2,
"nm": "左牌子 合成 2_00018.png",
"refId": "b0e41055f57df4dcf4ecfccbc656a63f",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
156.5,
0
]
},
"a": {
"k": [
162.5,
155.5,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 2,
"op": 3
},
{
"ind": 4,
"ty": 2,
"nm": "左牌子 合成 2_00019.png",
"refId": "cb50e329f0b82c3f0ce655a0f8be972b",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
156.5,
0
]
},
"a": {
"k": [
162.5,
155.5,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 3,
"op": 4
},
{
"ind": 5,
"ty": 2,
"nm": "左牌子 合成 2_00020.png",
"refId": "41c1d044db50f24c6a0487c298f75050",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
156.5,
0
]
},
"a": {
"k": [
162.5,
155.5,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 4,
"op": 5
},
{
"ind": 6,
"ty": 2,
"nm": "左牌子 合成 2_00021.png",
"refId": "28006e5a01c626254a11e2e81a546c43",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
161,
0
]
},
"a": {
"k": [
162.5,
159,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 5,
"op": 6
},
{
"ind": 7,
"ty": 2,
"nm": "左牌子 合成 2_00022.png",
"refId": "60051d951deade9bbb8223c4ba7e0f4a",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
166,
0
]
},
"a": {
"k": [
162.5,
164,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 6,
"op": 7
},
{
"ind": 8,
"ty": 2,
"nm": "左牌子 合成 2_00023.png",
"refId": "0164ce9f97c1351ee408f2bb47f40804",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
171.5,
0
]
},
"a": {
"k": [
162.5,
169.5,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 7,
"op": 8
},
{
"ind": 9,
"ty": 2,
"nm": "左牌子 合成 2_00024.png",
"refId": "b966bc1ca2b9a34764a2437c4215e8c9",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
178,
0
]
},
"a": {
"k": [
162.5,
176,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 8,
"op": 9
},
{
"ind": 10,
"ty": 2,
"nm": "左牌子 合成 2_00025.png",
"refId": "52a9792562c9f4ed30ace0155c711793",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
190.5,
0
]
},
"a": {
"k": [
162.5,
190.5,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 9,
"op": 10
},
{
"ind": 11,
"ty": 2,
"nm": "左牌子 合成 2_00026.png",
"refId": "a1c33bb4ac6bc12e368e4956e530e874",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
190.5,
0
]
},
"a": {
"k": [
162.5,
190.5,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 10,
"op": 11
},
{
"ind": 12,
"ty": 2,
"nm": "左牌子 合成 2_00027.png",
"refId": "3370e35def80441da5a39f0645d88706",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
156.5,
0
]
},
"a": {
"k": [
162.5,
155.5,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 11,
"op": 12
},
{
"ind": 13,
"ty": 2,
"nm": "左牌子 合成 2_00028.png",
"refId": "a33f4734da805886b130702b082982a9",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
156.5,
0
]
},
"a": {
"k": [
162.5,
155.5,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 12,
"op": 13
},
{
"ind": 14,
"ty": 2,
"nm": "左牌子 合成 2_00029.png",
"refId": "498ca4d3f629a6d00ed906b4d5e5e821",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
156.5,
0
]
},
"a": {
"k": [
162.5,
155.5,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 13,
"op": 14
},
{
"ind": 15,
"ty": 2,
"nm": "左牌子 合成 2_00030.png",
"refId": "d3c4b07c8a7de09c862417a6342bdeff",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
156.5,
0
]
},
"a": {
"k": [
162.5,
155.5,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 14,
"op": 15
},
{
"ind": 16,
"ty": 2,
"nm": "左牌子 合成 2_00031.png",
"refId": "9f0f64188bd84e6d239e36019b33bb40",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
156.5,
0
]
},
"a": {
"k": [
162.5,
155.5,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 15,
"op": 16
},
{
"ind": 17,
"ty": 2,
"nm": "左牌子 合成 2_00032.png",
"refId": "c6e16847929c5da97d053d17120a0d68",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
157,
0
]
},
"a": {
"k": [
162.5,
155,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 16,
"op": 17
},
{
"ind": 18,
"ty": 2,
"nm": "左牌子 合成 2_00033.png",
"refId": "8d31690f54217e3196991204cae42a11",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
157,
0
]
},
"a": {
"k": [
162.5,
155,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 17,
"op": 18
},
{
"ind": 19,
"ty": 2,
"nm": "左牌子 合成 2_00034.png",
"refId": "6dfac66424f05bb4084d963e4a9d09f0",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
160,
0
]
},
"a": {
"k": [
162.5,
158,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 18,
"op": 19
},
{
"ind": 20,
"ty": 2,
"nm": "左牌子 合成 2_00035.png",
"refId": "eee4d4b331764e60a6570a8874553bb9",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
165.5,
0
]
},
"a": {
"k": [
162.5,
163.5,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 19,
"op": 20
},
{
"ind": 21,
"ty": 2,
"nm": "左牌子 合成 2_00036.png",
"refId": "e8bf00e43a221c77ed7daf919f402ce1",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
171,
0
]
},
"a": {
"k": [
162.5,
168,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 20,
"op": 21
},
{
"ind": 22,
"ty": 2,
"nm": "左牌子 合成 2_00037.png",
"refId": "5d9932758c0ffdc7ab90c5f79d82fe5e",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
177,
0
]
},
"a": {
"k": [
162.5,
174,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 21,
"op": 22
},
{
"ind": 23,
"ty": 2,
"nm": "左牌子 合成 2_00038.png",
"refId": "6a6bd5e469cd0d59fb9e439f81217f3d",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
190.5,
0
]
},
"a": {
"k": [
162.5,
190.5,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 22,
"op": 23
},
{
"ind": 24,
"ty": 2,
"nm": "左牌子 合成 2_00039.png",
"refId": "f0d16f3820d2b525a8a7a0c8f72cd794",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
190.5,
0
]
},
"a": {
"k": [
162.5,
190.5,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 23,
"op": 24
}
],
"markers": [],
"tiny": 0.55
}
\ No newline at end of file
export const banner2 = {
"fr": 30,
"ip": 0,
"op": 24,
"w": 336,
"h": 358,
"nm": "右牌子 合成 1 - Auto Crop PreComp",
"layers": [
{
"ind": 1,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00000.png",
"refId": "b81f9dd63a41b0c87a7790043c62a95c",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
149.5,
0
]
},
"a": {
"k": [
168,
149.5,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 0,
"op": 1
},
{
"ind": 2,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00001.png",
"refId": "f764373c1caa0d42634ce916661160d5",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
149.5,
0
]
},
"a": {
"k": [
168,
149.5,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 1,
"op": 2
},
{
"ind": 3,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00002.png",
"refId": "d02fd69a469219be644bc49d4a31d59e",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
150,
0
]
},
"a": {
"k": [
168,
149,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 2,
"op": 3
},
{
"ind": 4,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00003.png",
"refId": "d451b9786349b1e706975daf4d8e2f85",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
150,
0
]
},
"a": {
"k": [
168,
149,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 3,
"op": 4
},
{
"ind": 5,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00004.png",
"refId": "412c0c261d3b89928e6f0b92f1a250b2",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
150,
0
]
},
"a": {
"k": [
168,
149,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 4,
"op": 5
},
{
"ind": 6,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00005.png",
"refId": "41bebcdee778b238ab274411a3f00e3c",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
150,
0
]
},
"a": {
"k": [
168,
149,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 5,
"op": 6
},
{
"ind": 7,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00006.png",
"refId": "1ccfc67ec7056d6d83dcdce617014657",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
150,
0
]
},
"a": {
"k": [
168,
149,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 6,
"op": 7
},
{
"ind": 8,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00007.png",
"refId": "77c9ccf6da03788bdd627e1241de1a44",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
150.5,
0
]
},
"a": {
"k": [
168,
148.5,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 7,
"op": 8
},
{
"ind": 9,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00008.png",
"refId": "90cea1bb2c83fd8df25c1c3541da0b01",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
154,
0
]
},
"a": {
"k": [
168,
152,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 8,
"op": 9
},
{
"ind": 10,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00009.png",
"refId": "1b6e94c28a073e8ab266a8c4a813378e",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
159.5,
0
]
},
"a": {
"k": [
168,
157.5,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 9,
"op": 10
},
{
"ind": 11,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00010.png",
"refId": "05f565f4e9257b665a779bf070daec1c",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
164,
0
]
},
"a": {
"k": [
168,
164,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 10,
"op": 11
},
{
"ind": 12,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00011.png",
"refId": "71c8647355e187f452c7a22148b1a2b7",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
170,
0
]
},
"a": {
"k": [
168,
170,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 11,
"op": 12
},
{
"ind": 13,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00012.png",
"refId": "30d0615c544780879a52287e6e0d7e28",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
179,
0
]
},
"a": {
"k": [
168,
179,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 12,
"op": 13
},
{
"ind": 14,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00013.png",
"refId": "b7344d455c9e425b3594dc984c45e2bd",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
150,
0
]
},
"a": {
"k": [
168,
149,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 13,
"op": 14
},
{
"ind": 15,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00014.png",
"refId": "6f807cbbf5e4684a193fdd5487ce7252",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
150,
0
]
},
"a": {
"k": [
168,
149,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 14,
"op": 15
},
{
"ind": 16,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00015.png",
"refId": "7aa0605d9803d2f0995411738bd28cdb",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
150,
0
]
},
"a": {
"k": [
168,
149,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 15,
"op": 16
},
{
"ind": 17,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00016.png",
"refId": "2d73d2d9da9b09fecfef6805a373ab85",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
150,
0
]
},
"a": {
"k": [
168,
149,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 16,
"op": 17
},
{
"ind": 18,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00017.png",
"refId": "c3007d8328a0639c5eceb80892615f38",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
150,
0
]
},
"a": {
"k": [
168,
149,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 17,
"op": 18
},
{
"ind": 19,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00018.png",
"refId": "40868c37b8e8ae5f4382d2a1f59bac3a",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
150.5,
0
]
},
"a": {
"k": [
168,
148.5,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 18,
"op": 19
},
{
"ind": 20,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00019.png",
"refId": "9c88ef64a01ca17439d550c60f168eb5",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
156,
0
]
},
"a": {
"k": [
168,
154,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 19,
"op": 20
},
{
"ind": 21,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00020.png",
"refId": "024280fed19ab27076c5603959501914",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
161,
0
]
},
"a": {
"k": [
168,
159,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 20,
"op": 21
},
{
"ind": 22,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00021.png",
"refId": "7cda9a80d6188909df0db43e457dbfb1",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
166.5,
0
]
},
"a": {
"k": [
168,
164.5,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 21,
"op": 22
},
{
"ind": 23,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00022.png",
"refId": "7f16355a569cc7eb9969b981b4634ff5",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
179,
0
]
},
"a": {
"k": [
168,
179,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 22,
"op": 23
},
{
"ind": 24,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00023.png",
"refId": "a54f77095632eeb1a66a157dba068741",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
179,
0
]
},
"a": {
"k": [
168,
179,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 23,
"op": 24
}
],
"markers": [],
"tiny": 0.55
}
\ No newline at end of file
export const leftBanner = {
"fr": 30,
"ip": 0,
"op": 24,
"w": 336,
"h": 358,
"nm": "右牌子 合成 1 - Auto Crop PreComp",
"layers": [
{
"ind": 1,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00000.png",
"refId": "b81f9dd63a41b0c87a7790043c62a95c",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
149.5,
0
]
},
"a": {
"k": [
168,
149.5,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 0,
"op": 1
},
{
"ind": 2,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00001.png",
"refId": "f764373c1caa0d42634ce916661160d5",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
149.5,
0
]
},
"a": {
"k": [
168,
149.5,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 1,
"op": 2
},
{
"ind": 3,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00002.png",
"refId": "d02fd69a469219be644bc49d4a31d59e",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
150,
0
]
},
"a": {
"k": [
168,
149,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 2,
"op": 3
},
{
"ind": 4,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00003.png",
"refId": "d451b9786349b1e706975daf4d8e2f85",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
150,
0
]
},
"a": {
"k": [
168,
149,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 3,
"op": 4
},
{
"ind": 5,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00004.png",
"refId": "412c0c261d3b89928e6f0b92f1a250b2",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
150,
0
]
},
"a": {
"k": [
168,
149,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 4,
"op": 5
},
{
"ind": 6,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00005.png",
"refId": "41bebcdee778b238ab274411a3f00e3c",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
150,
0
]
},
"a": {
"k": [
168,
149,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 5,
"op": 6
},
{
"ind": 7,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00006.png",
"refId": "1ccfc67ec7056d6d83dcdce617014657",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
150,
0
]
},
"a": {
"k": [
168,
149,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 6,
"op": 7
},
{
"ind": 8,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00007.png",
"refId": "77c9ccf6da03788bdd627e1241de1a44",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
150.5,
0
]
},
"a": {
"k": [
168,
148.5,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 7,
"op": 8
},
{
"ind": 9,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00008.png",
"refId": "90cea1bb2c83fd8df25c1c3541da0b01",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
154,
0
]
},
"a": {
"k": [
168,
152,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 8,
"op": 9
},
{
"ind": 10,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00009.png",
"refId": "1b6e94c28a073e8ab266a8c4a813378e",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
159.5,
0
]
},
"a": {
"k": [
168,
157.5,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 9,
"op": 10
},
{
"ind": 11,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00010.png",
"refId": "05f565f4e9257b665a779bf070daec1c",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
164,
0
]
},
"a": {
"k": [
168,
164,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 10,
"op": 11
},
{
"ind": 12,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00011.png",
"refId": "71c8647355e187f452c7a22148b1a2b7",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
170,
0
]
},
"a": {
"k": [
168,
170,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 11,
"op": 12
},
{
"ind": 13,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00012.png",
"refId": "30d0615c544780879a52287e6e0d7e28",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
179,
0
]
},
"a": {
"k": [
168,
179,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 12,
"op": 13
},
{
"ind": 14,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00013.png",
"refId": "b7344d455c9e425b3594dc984c45e2bd",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
150,
0
]
},
"a": {
"k": [
168,
149,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 13,
"op": 14
},
{
"ind": 15,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00014.png",
"refId": "6f807cbbf5e4684a193fdd5487ce7252",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
150,
0
]
},
"a": {
"k": [
168,
149,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 14,
"op": 15
},
{
"ind": 16,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00015.png",
"refId": "7aa0605d9803d2f0995411738bd28cdb",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
150,
0
]
},
"a": {
"k": [
168,
149,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 15,
"op": 16
},
{
"ind": 17,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00016.png",
"refId": "2d73d2d9da9b09fecfef6805a373ab85",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
150,
0
]
},
"a": {
"k": [
168,
149,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 16,
"op": 17
},
{
"ind": 18,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00017.png",
"refId": "c3007d8328a0639c5eceb80892615f38",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
150,
0
]
},
"a": {
"k": [
168,
149,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 17,
"op": 18
},
{
"ind": 19,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00018.png",
"refId": "40868c37b8e8ae5f4382d2a1f59bac3a",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
150.5,
0
]
},
"a": {
"k": [
168,
148.5,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 18,
"op": 19
},
{
"ind": 20,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00019.png",
"refId": "9c88ef64a01ca17439d550c60f168eb5",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
156,
0
]
},
"a": {
"k": [
168,
154,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 19,
"op": 20
},
{
"ind": 21,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00020.png",
"refId": "024280fed19ab27076c5603959501914",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
161,
0
]
},
"a": {
"k": [
168,
159,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 20,
"op": 21
},
{
"ind": 22,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00021.png",
"refId": "7cda9a80d6188909df0db43e457dbfb1",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
166.5,
0
]
},
"a": {
"k": [
168,
164.5,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 21,
"op": 22
},
{
"ind": 23,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00022.png",
"refId": "7f16355a569cc7eb9969b981b4634ff5",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
179,
0
]
},
"a": {
"k": [
168,
179,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 22,
"op": 23
},
{
"ind": 24,
"ty": 2,
"nm": "右牌子 合成 1 - Auto Crop PreComp_00023.png",
"refId": "a54f77095632eeb1a66a157dba068741",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
168,
179,
0
]
},
"a": {
"k": [
168,
179,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 23,
"op": 24
}
],
"markers": [],
"tiny": 0.55
}
\ No newline at end of file
export const rightBanner = {
"fr": 30,
"ip": 0,
"op": 24,
"w": 325,
"h": 381,
"nm": "左牌子222222",
"layers": [
{
"ind": 1,
"ty": 2,
"nm": "左牌子 合成 2_00016.png",
"refId": "9714def3226819a6055515694f08ab94",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
156.5,
0
]
},
"a": {
"k": [
162.5,
155.5,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 0,
"op": 1
},
{
"ind": 2,
"ty": 2,
"nm": "左牌子 合成 2_00017.png",
"refId": "78b3a03e48d1068c2a3de2e940775cfc",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
156.5,
0
]
},
"a": {
"k": [
162.5,
155.5,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 1,
"op": 2
},
{
"ind": 3,
"ty": 2,
"nm": "左牌子 合成 2_00018.png",
"refId": "b0e41055f57df4dcf4ecfccbc656a63f",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
156.5,
0
]
},
"a": {
"k": [
162.5,
155.5,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 2,
"op": 3
},
{
"ind": 4,
"ty": 2,
"nm": "左牌子 合成 2_00019.png",
"refId": "cb50e329f0b82c3f0ce655a0f8be972b",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
156.5,
0
]
},
"a": {
"k": [
162.5,
155.5,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 3,
"op": 4
},
{
"ind": 5,
"ty": 2,
"nm": "左牌子 合成 2_00020.png",
"refId": "41c1d044db50f24c6a0487c298f75050",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
156.5,
0
]
},
"a": {
"k": [
162.5,
155.5,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 4,
"op": 5
},
{
"ind": 6,
"ty": 2,
"nm": "左牌子 合成 2_00021.png",
"refId": "28006e5a01c626254a11e2e81a546c43",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
161,
0
]
},
"a": {
"k": [
162.5,
159,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 5,
"op": 6
},
{
"ind": 7,
"ty": 2,
"nm": "左牌子 合成 2_00022.png",
"refId": "60051d951deade9bbb8223c4ba7e0f4a",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
166,
0
]
},
"a": {
"k": [
162.5,
164,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 6,
"op": 7
},
{
"ind": 8,
"ty": 2,
"nm": "左牌子 合成 2_00023.png",
"refId": "0164ce9f97c1351ee408f2bb47f40804",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
171.5,
0
]
},
"a": {
"k": [
162.5,
169.5,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 7,
"op": 8
},
{
"ind": 9,
"ty": 2,
"nm": "左牌子 合成 2_00024.png",
"refId": "b966bc1ca2b9a34764a2437c4215e8c9",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
178,
0
]
},
"a": {
"k": [
162.5,
176,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 8,
"op": 9
},
{
"ind": 10,
"ty": 2,
"nm": "左牌子 合成 2_00025.png",
"refId": "52a9792562c9f4ed30ace0155c711793",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
190.5,
0
]
},
"a": {
"k": [
162.5,
190.5,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 9,
"op": 10
},
{
"ind": 11,
"ty": 2,
"nm": "左牌子 合成 2_00026.png",
"refId": "a1c33bb4ac6bc12e368e4956e530e874",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
190.5,
0
]
},
"a": {
"k": [
162.5,
190.5,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 10,
"op": 11
},
{
"ind": 12,
"ty": 2,
"nm": "左牌子 合成 2_00027.png",
"refId": "3370e35def80441da5a39f0645d88706",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
156.5,
0
]
},
"a": {
"k": [
162.5,
155.5,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 11,
"op": 12
},
{
"ind": 13,
"ty": 2,
"nm": "左牌子 合成 2_00028.png",
"refId": "a33f4734da805886b130702b082982a9",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
156.5,
0
]
},
"a": {
"k": [
162.5,
155.5,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 12,
"op": 13
},
{
"ind": 14,
"ty": 2,
"nm": "左牌子 合成 2_00029.png",
"refId": "498ca4d3f629a6d00ed906b4d5e5e821",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
156.5,
0
]
},
"a": {
"k": [
162.5,
155.5,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 13,
"op": 14
},
{
"ind": 15,
"ty": 2,
"nm": "左牌子 合成 2_00030.png",
"refId": "d3c4b07c8a7de09c862417a6342bdeff",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
156.5,
0
]
},
"a": {
"k": [
162.5,
155.5,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 14,
"op": 15
},
{
"ind": 16,
"ty": 2,
"nm": "左牌子 合成 2_00031.png",
"refId": "9f0f64188bd84e6d239e36019b33bb40",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
156.5,
0
]
},
"a": {
"k": [
162.5,
155.5,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 15,
"op": 16
},
{
"ind": 17,
"ty": 2,
"nm": "左牌子 合成 2_00032.png",
"refId": "c6e16847929c5da97d053d17120a0d68",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
157,
0
]
},
"a": {
"k": [
162.5,
155,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 16,
"op": 17
},
{
"ind": 18,
"ty": 2,
"nm": "左牌子 合成 2_00033.png",
"refId": "8d31690f54217e3196991204cae42a11",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
157,
0
]
},
"a": {
"k": [
162.5,
155,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 17,
"op": 18
},
{
"ind": 19,
"ty": 2,
"nm": "左牌子 合成 2_00034.png",
"refId": "6dfac66424f05bb4084d963e4a9d09f0",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
160,
0
]
},
"a": {
"k": [
162.5,
158,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 18,
"op": 19
},
{
"ind": 20,
"ty": 2,
"nm": "左牌子 合成 2_00035.png",
"refId": "eee4d4b331764e60a6570a8874553bb9",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
165.5,
0
]
},
"a": {
"k": [
162.5,
163.5,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 19,
"op": 20
},
{
"ind": 21,
"ty": 2,
"nm": "左牌子 合成 2_00036.png",
"refId": "e8bf00e43a221c77ed7daf919f402ce1",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
171,
0
]
},
"a": {
"k": [
162.5,
168,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 20,
"op": 21
},
{
"ind": 22,
"ty": 2,
"nm": "左牌子 合成 2_00037.png",
"refId": "5d9932758c0ffdc7ab90c5f79d82fe5e",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
177,
0
]
},
"a": {
"k": [
162.5,
174,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 21,
"op": 22
},
{
"ind": 23,
"ty": 2,
"nm": "左牌子 合成 2_00038.png",
"refId": "6a6bd5e469cd0d59fb9e439f81217f3d",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
190.5,
0
]
},
"a": {
"k": [
162.5,
190.5,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 22,
"op": 23
},
{
"ind": 24,
"ty": 2,
"nm": "左牌子 合成 2_00039.png",
"refId": "f0d16f3820d2b525a8a7a0c8f72cd794",
"ks": {
"o": {
"k": 100
},
"r": {
"k": 0
},
"p": {
"k": [
162.5,
190.5,
0
]
},
"a": {
"k": [
162.5,
190.5,
0
]
},
"s": {
"k": [
100,
100,
100
]
}
},
"ip": 23,
"op": 24
}
],
"markers": [],
"tiny": 0.55
}
\ No newline at end of file
import { Tools } from './../Tools';
import { RES } from "../../module/RES"
import { Pos } from "./GameScene/ConveyorBelt"
import { GDispatcher } from '../Main';
import { ConveyorBeltGameEle } from './GameScene/ConveyorBeltConfig';
import UI from '../UI';
export interface GameEleInfer {
type: number,
res: string,
score?: number | undefined
}
export class GameEle extends FYGE.Sprite {
_resType: string // 游戏元素type src
_resType2: string | number // 游戏元素类型 0, 1, 2
_score: number
constructor(config:GameEleInfer) {
super(RES.getRes(config.res))
this._resType = config.res
this._resType2 = config.type
this._score = config.score
// const l = UI.Sp(this, 'com_light2.png')
// this.setChildIndex(l, -100)
}
onCollision() {
if (this._resType2 == 1) {
GDispatcher.dispatchEvent('update-score', {
score: this._score
})
this.onShowScoreAni(`+${this._score}`, {
x: this.x,
y: this.y
})
} else if (this._resType2 == 0) {
GDispatcher.dispatchEvent('game-over')
} else {
GDispatcher.dispatchEvent('rabbit-buff')
}
}
onShowLightRatation() {
}
onShowScoreAni(scoreText: string, pos: Pos) {
const BitmapTextTextures = Tools.getNumTextures('score')
BitmapTextTextures['+'] = RES.getRes('score+.png')
const BitmapText = new FYGE.BitmapText(BitmapTextTextures)
this.parent.parent.addChild(BitmapText)
BitmapText.text = scoreText
BitmapText.alpha = 0
BitmapText.position.set(pos.x, pos.y)
FYGE.Tween.get(BitmapText)
.to({ y: pos.y - 150, alpha: 1 }, 600)
.wait(300)
.to({alpha: 0}, 300)
.call(() => {
BitmapText.destroy()
})
}
}
\ No newline at end of file
import { GameEle, GameEleInfer } from './../GameEle';
import { GPool } from './../../../module/tools/GPool';
import Clock from '../../Clock'
import { getRandomArrItem, spliceArrItem } from '../../utils/utils'
import { ConveyorBeltGameEle } from './ConveyorBeltConfig'
import { RES } from '../../../module/RES';
import { getRandomArrayElements } from '../../Tools';
import { RabbitPos } from './GameSceneConfig';
import { GDispatcher } from '../../Main';
// 非障碍元素
const CollsionEle = ConveyorBeltGameEle.filter(item => item.type)
export interface Pos {
x: number
y: number
}
interface ConveyorBeltInfer {
start: Pos
end: Pos,
obstacleFunc: Function, // 障碍出现逻辑
onBehindFromRabbit: Function
}
export class ConveyorBelt extends FYGE.Container {
ConveyorBeltConfigData: ConveyorBeltInfer
speed: number = 200 // 传送带速度 这里就是 y方向上的速度 200 - 650
spt: number // 每隔多长时间会出现下一个
spl: number = 300 // 距离
clock: Clock
tanValue: number // tan 值
conveyorItems: Array<GameEle> = [] // 传送带上的 item
isStarted: boolean = false // 是否开始
totalDisY: number
startY: number
constructor(data: ConveyorBeltInfer) {
super()
this.ConveyorBeltConfigData = data
this.clock = new Clock()
this.startY = data.start.y
this.tanValue = Math.abs(data.start.x - data.end.x) ? (data.start.y - data.end.y) / (data.start.x - data.end.x) : 0
this.initEvents()
this.totalDisY = Math.abs(data.start.y - data.end.y)
}
/**
* 切换坐标跟随 y值
* @param target
* @param changeY
*/
onChangePosByY(target: GameEle, changeY: number) {
if (!this.tanValue) {
} else {
target.x += changeY / this.tanValue
}
target.y += changeY
const yp = changeY / (this.totalDisY * 0.6)
// target.alpha += yp
target.scaleX += yp
target.scaleY += yp
if (target.y >= this.ConveyorBeltConfigData.end.y) {
this.popConveyor(target)
}
if (target.y >= RabbitPos.y + 200) {
this.ConveyorBeltConfigData.onBehindFromRabbit(target)
}
}
initEvents() {
this.addEventListener(FYGE.Event.ENTER_FRAME, this.onUpdate, this)
}
removeEvents() {
this.removeEventListener(FYGE.Event.ENTER_FRAME, this.onUpdate, this)
}
// 因为碰撞或者移动出去的 销毁
popConveyor(item: GameEle, didu?: boolean) {
if (didu) {
item.onCollision()
}
item.visible = false
spliceArrItem(this.conveyorItems, item)
GPool.takeIn(item['_resType'], item)
}
onReset() {
for (var i = this.conveyorItems.length- 1; i >= 0; i--) {
this.popConveyor(this.conveyorItems[i])
}
}
popConveyorItems(item: GameEle) {
spliceArrItem(this.conveyorItems, item)
}
destroy(): void {
super.destroy()
GPool.clear()
this.removeEvents()
}
/**
* 是否可以
* @param n
*/
isHaveObstacleNearBy(n: number = 200) {
// 找到所有 非障碍item
const obstacleList = this.conveyorItems.filter(i => !i._resType2)
return !obstacleList || obstacleList.every(item => (item.y - this.startY) > n)
}
/**
* 开始出现元素
*/
start() {
this.isStarted = true
// getRandomArrayElements
this.onRenderGameEleData()
this.clock.restart()
}
stop() {
this.isStarted = false
}
onRenderGameEleData() {
const item = getRandomArrItem(ConveyorBeltGameEle)
if (item.type) {
if (item.type == 2) {
GDispatcher.dispatchEvent('show-radish')
ConveyorBeltGameEle.pop()
}
this.onInitGameElement(item)
} else {
const isShouldRenderObstacle = this.ConveyorBeltConfigData.obstacleFunc()
console.log('是否选择障碍:', isShouldRenderObstacle)
if (isShouldRenderObstacle) {
this.onInitGameElement(item)
} else {
this.onInitGameElement(getRandomArrItem(CollsionEle))
}
}
}
/**
* 开始渲染传送带游戏元素
*/
onInitGameElement(config:GameEleInfer) {
this.spl = Math.floor(Math.random() * 200 + 300)
this.spt = this.spl / this.speed
const ConveyorItem = GPool.takeOut<GameEle>(config.res) || new GameEle(config)
this.addChild(ConveyorItem)
ConveyorItem.anchorTexture.set(0.5, 0.5)
ConveyorItem.scale.set(0)
ConveyorItem.visible = true
this.setChildIndex(ConveyorItem, 100)
ConveyorItem.position.set(this.ConveyorBeltConfigData.start.x, this.ConveyorBeltConfigData.start.y)
// ConveyorItem._resType = config.res
// ConveyorItem._resType2 = config.type
this.conveyorItems.push(ConveyorItem)
}
onUpdate() {
if (!this.isStarted) return
var elapsedTime = this.clock.getElapsedTime()
if (elapsedTime > this.spt) {
this.onRenderGameEleData()
this.clock.reset()
}
const diff = this.clock.getDelta()
this.conveyorItems.forEach(item => this.onChangePosByY(item, diff * this.speed))
}
}
\ No newline at end of file
export const ConveyorBeltGameEle = [
{
type: 1,
res: 'Star.png',
score: 5
},
{
type: 1,
res: 'PrizeCard.png',
score: 10
},
{
type: 0,
res: 'SnowBall.png'
}
]
export const specialGameEle = [
{
type: 2,
res: 'Radish.png'
}
]
\ No newline at end of file
import { LOG_TYPE } from './../../WebNet';
import { Tools } from './../../Tools';
import { changeScene } from './../../../module/ctrls/index';
import { GPool } from './../../../module/tools/GPool';
import { GameEle } from './../GameEle';
import { ProgressBar } from './../../common/ProgressBar';
import { RES } from '../../../module/RES';
import { GDispatcher } from '../../Main';
import UI from '../../UI';
import { onceFnc, padStart, spliceArrItem } from '../../utils/utils';
import { NewGuyScene } from '../NewGuyScene/NewGuyScene';
import { Scene } from './../../../module/views/Scene';
import { ConveyorBelt, Pos } from './ConveyorBelt';
import { RabbitPos, GameCfg } from './GameSceneConfig';
import { getTbData, sendTbNet, TbNetName } from '../../TaoBaoNet';
import { layers } from '../../../module/views/layers';
import { countDown } from '../../common/countDown';
import { ConveyorBeltGameEle, specialGameEle } from './ConveyorBeltConfig';
import { showPanel } from '../../../module/ctrls';
import { GameOverPanel } from '../../components/GameOverPanel';
import IndexScene from '../IndexScene';
import CircleProgressBar from '../../common/CircleProgressBar';
import { sendLog } from '../../WebNet'
const MD5 = require('js-md5')
export class RadishCountDown extends FYGE.Container {
allTime: number = 0
constructor(data: number) {
super()
this.allTime = data
this.initUi()
}
_value: number = 0
get value() {
return this._value
}
set value(v) {
this._value = v
this.CircleProgressBar.value = v
}
CircleProgressBar: CircleProgressBar
bitmapTexture: FYGE.BitmapText
initUi() {
var radish = UI.Sp(this, 'Radish.png')
radish.scale.set(.7)
radish.position.set(-20, -30)
var c = this.CircleProgressBar= this.addChild(new CircleProgressBar({
circleColor: 0xcfdf74,
backColor: 0x212c43,
radius: 40,
lineWidth: 16
}))
var textures = Tools.getNumTextures('gn')
textures[':'] = RES.getRes('gnm.png')
this.bitmapTexture = this.addChild(new FYGE.BitmapText(textures))
this.bitmapTexture.position.set(0, 50)
// this.bitmapTexture.scale
c.value = 0
}
reStart() {
this.CircleProgressBar.value = 0
this.bitmapTexture.text = '00:00'
FYGE.Tween.get(this.CircleProgressBar, {
onChange: () => {
this.bitmapTexture.text = `00:0${5 - (this.CircleProgressBar.value * this.allTime / 1000) >> 0}`
}
})
.to({value: 1}, this.allTime)
}
stop() {
FYGE.Tween.removeTweens(this.CircleProgressBar)
}
}
function SetMouseEventNode(con: FYGE.Container) {
con.mouseChildren = false
con.mouseEnable = false
}
export class GameScene extends Scene {
Rabbit: FYGE.MovieClip
RabbitCont: FYGE.Container
touchStartX: number | null
rabbitPosXList = [-60, 250, 560]
_currRabbitIndex = 1
conveyorList: Array<ConveyorBelt> = []
GameStatus: number = 0 // 未开始0 1 开始 2萝卜
operationCont: FYGE.Container
runway: FYGE.MovieClip
buildings: FYGE.MovieClip
isNewGuy: boolean
_score: number
scoreText: FYGE.TextField
skiingScoreRewardCreditsList: Array<any> // 目标分数
maxScore: number = 0
goalList: Array<FYGE.Sprite> = [] // 目标
currProgressIns: ProgressBar
currGoalIndex: number = 0
GameDataFromInfer: any
cdt: FYGE.TextField
RadishCountDown: RadishCountDown
get score() {
return this._score
}
set score(v) {
if (v === undefined) return
this._score = v
this.scoreText.text = padStart(v, 4, '0') + '分'
this.currProgressIns.value = v / this.maxScore
const mi = this.skiingScoreRewardCreditsList.findIndex(item => item.score > v)
for (let index = this.currGoalIndex; index < (mi == -1 ? this.goalList.length : mi); index++) {
// @ts-ignore
this.goalList[index].texture = RES.getRes(this.goalList[index]._goalImage+'.png')
}
}
get currRabbitIndex() {
return this._currRabbitIndex
}
set currRabbitIndex(v) {
if (!this.rabbitPosXList[v]) return
if (v == this._currRabbitIndex) return
this._currRabbitIndex = v
FYGE.Tween.removeTweens(this.RabbitCont)
FYGE.Tween.get(this.RabbitCont)
.to({x: this.rabbitPosXList[v]}, 100 * 310 / Math.abs(this.rabbitPosXList[v] - this.RabbitCont.x))
// for (var i = this.TweenList.length - 1; i >= 0; i --) {
// const ins = this.TweenList[i]
// FYGE.Tween.removeTweens(ins)
// spliceArrItem(this.TweenList, ins)
// this.onTween2Rabbit(ins)
// }
}
get groupNames(): string[] {
return ['GameScene', 'svga']
}
initUi() {
this.GameDataFromInfer = getTbData(TbNetName.doIndex).data
GameCfg.totalTime = this.GameDataFromInfer.skiingCountdownSeconds
UI.Sp(this, 'GameSceneBack.png')
const runway = this.runway = this.addChild(new FYGE.MovieClip(RES.getRes('游戏道路循环.svga')))
runway.mouseChildren = false
runway.mouseEnable = false
// runway.fps = 10
const buildings = this.buildings = this.addChild(new FYGE.MovieClip(RES.getRes('左右建筑.svga')))
buildings.mouseChildren = false
buildings.mouseEnable = false
// buildings.fps = 10
this.conveyorList.push(this.onInitConveyor({
x: 420,
y: 475
}, {
x: 750,
y: 1624
}))
this.conveyorList.push(this.onInitConveyor({
x: 370,
y: 475
}, {
x: 365,
y: 1624
}))
this.conveyorList.push(this.onInitConveyor({
x: 320,
y: 475
}, {
x: 0,
y: 1624
}))
const ScoreCont = UI.Ctn(this, 280, 230)
UI.Sp(ScoreCont, 'score-back.png')
this.scoreText = UI.Txt(ScoreCont, '0', 36, '#ffffff', FYGE.TEXT_ALIGN.LEFT, 400, 100, 10, true)
this.onInitNormalScoreGoalBoard()
// @ts-ignore
const RabbitCont = this.RabbitCont = UI.Ctn(this, 250, RabbitPos.y)
const Rabbit = this.Rabbit = RabbitCont.addChild(new FYGE.MovieClip(RES.getRes('游戏兔子.svga')))
const CountDownCom = UI.Ctn(this, 650, 300)
UI.Sp(CountDownCom, 'countDown-back.png')
const cdt = this.cdt = UI.Txt(CountDownCom, `${getTbData(TbNetName.doIndex).data.skiingCountdownSeconds}s`, 30, '#b1231c', FYGE.TEXT_ALIGN.CENTER, 80, 0, 40, true)
// this.addChild(new FYGE.MovieClip(RES.getRes('游戏兔子.svga')))
// Rabbit.anchor.set(0.5)
// Rabbit.position.set()
// this.setChildIndex(Rabbit, 1)
// var c = this.addChild(new RadishCountDown(5000))
// c.position.set(690, 370)
}
/**
* 初始化 分数目标版
*/
onInitNormalScoreGoalBoard() {
const board = UI.Ctn(this, (750 - 459) / 2, 300)
UI.Sp(board, 'progress-back.png')
const p = this.currProgressIns = board.addChild(new ProgressBar(0xffd900, {
showProgressText: false,
type: 'fill',
typeColor: 0x63211b,
width: 390,
height: 12
}))
p.position.set(33, 80)
UI.Sp(p, 'progress-point.png', -10, -4)
UI.Sp(p, 'goal0', 0, -35, true)
const skiingScoreRewardCreditsList = this.skiingScoreRewardCreditsList = getTbData(TbNetName.doIndex).data.skiingScoreRewardCreditsList
const finalScore = this.maxScore = skiingScoreRewardCreditsList.slice(-1)[0].score
for (let i = 0; i < skiingScoreRewardCreditsList.length; i++) {
const goal = skiingScoreRewardCreditsList[i];
UI.Sp(p, 'progress-point.png',goal.score / finalScore * 390 - 10, -4)
const gi = UI.Sp(p, i < skiingScoreRewardCreditsList.length -1 ? 'giftbox-disabled' : 'finalgiftbox-disabled', goal.score / finalScore * 390 - 20, -55)
UI.Txt(p, `${goal.score}分`, 24, '#c14c3b', FYGE.TEXT_ALIGN.LEFT, 200, goal.score / finalScore * 390 - 20, 20)
// @ts-ignore
gi._goalImage = i < skiingScoreRewardCreditsList.length -1 ? 'giftbox' : 'finalgiftbox'
this.goalList.push(gi)
}
}
/**
* 初始化 倒计时
*/
CountDownTween: any
onInitCountDownCom() {
const totalTime = GameCfg.totalTime
const addRadish = onceFnc(() => {
// 添加萝卜
ConveyorBeltGameEle.push(...specialGameEle)
})
this.CountDownTween = countDown(totalTime * 1000, (t) => {
const ct = (t / 1000 >> 0)
this.cdt.text = ct+ 's'
if (t > totalTime * 1 / 3 * 1000 ) {
this.conveyorList.forEach(item => {
item.speed = 200 + (650 - 200) * (totalTime * 1000 - t) / (totalTime * 1000)
})
}
if (ct === totalTime - this.RadishTimeout) {
addRadish()
}
}, () => {
this.onGameOver()
})
}
RadishTimeout: number
start(data: any) {
super.start()
this.isNewGuy = data.isNewGuy
this.onStop()
if (this.isNewGuy) {
this.RabbitCont.visible = false
this.addChild(new NewGuyScene(async () => {
await sendTbNet(TbNetName.doModifySkiingGuideFlag, {
flag: 1
})
const { success, data } = await sendTbNet(TbNetName.doStart, null, null, true)
if (!success) {
changeScene(IndexScene)
return
}
this.RabbitCont.visible = true
this.onStart()
}))
} else {
// @ts-ignore
window.test = this.onShowRadishTips.bind(this)
this.onStart()
}
}
onStop() {
this.RadishTimeout = null
this.GameStatus = 0
this.Rabbit.stop()
this.runway.stop()
this.buildings.stop()
this.conveyorList.forEach(item => item.stop())
this.CountDownTween && FYGE.Tween.removeTweens(this.CountDownTween)
}
CountDownSvga: FYGE.MovieClip
onStart() {
this.score = 0
this.cdt.text = `${getTbData(TbNetName.doIndex).data.skiingCountdownSeconds}s`
this.conveyorList.forEach(con => con.onReset())
let s: FYGE.MovieClip
this.currRabbitIndex = 1
this.goalList && this.goalList.forEach(item => {
// @ts-ignore
item.texture = RES.getRes(item._goalImage+'-disabled.png')
})
if (this.CountDownSvga) {
s = this.CountDownSvga
} else {
s = this.CountDownSvga = this.addChild(new FYGE.MovieClip(RES.getRes('游戏倒计时 2.svga')))
s.position.set(layers.stageCenterX - 150, layers.stageCenterY - 100)
}
s.startAniRange(1, s.totalFrames, 1, () => {
this.GameStatus = 1
this.Rabbit.play()
this.runway.play()
this.buildings.play()
this.onInitCountDownCom() // 开始倒计时
this.conveyorList.forEach(item => item.start())
if (getTbData(TbNetName.doStart).data.haveRadish) {
this.RadishTimeout = Math.floor(Math.random() * 6 + 5)
}
})
// s.play(1, () => {
// this.GameStatus = 1
// this.Rabbit.play()
// this.runway.play()
// this.buildings.play()
// this.onInitCountDownCom() // 开始倒计时
// this.conveyorList.forEach(item => item.start())
// if (getTbData(TbNetName.doStart).data.haveRadish) {
// this.RadishTimeout = Math.floor(Math.random() * 6 + 5)
// }
// })
}
async onGameOver() {
this.onStop()
const {success, data} = await sendTbNet(TbNetName.doSubmit, {
startId: getTbData(TbNetName.doStart).data.startId,
score: this.score,
signStr: MD5(`${getTbData(TbNetName.doStart).data.startId}_${this.score}_1696BD3E5BB915A0`)
})
if (success) {
showPanel(GameOverPanel, Object.assign(data, {
onGameRestart: this.onGameRestart
}))
}
}
onGameRestart = async () => {
const { success, data } = await sendTbNet(TbNetName.doStart, null, null, true)
if (success) {
this.onStart()
} else {
changeScene(IndexScene)
}
}
/**
* 修改buff
* @param cfg
*/
onChangeBuffStatus(cfg?:any) {
if (cfg) {
if (!this.RadishCountDown) {
this.RadishCountDown = this.addChild(new RadishCountDown(5000))
this.RadishCountDown.position.set(690, 370)
}
this.RadishCountDown.visible = true
this.RadishCountDown.reStart()
this.GameStatus = 2
const t = (this.RabbitCont.children[1] || this.RabbitCont.addChild(new FYGE.MovieClip(RES.getRes('道具光环.svga'))));
t.position.set(-110, 40)
t.visible = true
countDown(5000, null, () => {
this.onChangeBuffStatus(false)
})
} else {
this.RadishCountDown.visible = false
this.GameStatus = 1
this.RabbitCont.children[1] && (this.RabbitCont.children[1].visible = false)
}
}
onInitConveyor(from: Pos, to: Pos) {
const conveyor = this.addChild(new ConveyorBelt({
start: from,
end: to,
obstacleFunc: this.isShouldOutObstacle,
onBehindFromRabbit: this.onBehindFromRabbit
}))
SetMouseEventNode(conveyor)
return conveyor
}
/**
* 显示逻辑提示
*/
onShowRadishTips() {
const tips = UI.Ctn(this, layers.stageCenterX - 592 / 2, 400)
UI.Sp(tips, 'radish-tips.png')
var r = tips.addChild(new GameEle(specialGameEle[0]))
r.position.set((tips.width - r.width) / 2, 30)
tips.anchorX = 592 / 2
tips.anchorY = tips.height / 2
tips.scale.set(0)
FYGE.Tween.get(tips)
.to({ scaleX: 1, scaleY: 1 }, 600, FYGE.Ease.quadIn)
.wait(1500)
.to({ alpha: 0 }, 300)
.call(() => {
tips.visible = false
})
}
/**
* 放游戏元素显示在上面
*/
onBehindFromRabbit = (d: any) => {
this.addChild(d)
}
isShouldOutObstacle = () => {
return this.conveyorList.every(item => item.isHaveObstacleNearBy(300))
}
initEvents(): void {
this.addEventListener(FYGE.MouseEvent.MOUSE_DOWN, this.onTouchStart, this)
this.addEventListener(FYGE.MouseEvent.MOUSE_UP, this.onTouchUp, this)
this.addEventListener(FYGE.Event.ENTER_FRAME, this.onUpdate, this)
GDispatcher.addEventListener('update-score', this.onUpdateScore, this)
GDispatcher.addEventListener('game-over', this.onGameOver, this)
GDispatcher.addEventListener('show-radish', this.onShowRadishTips, this)
GDispatcher.addEventListener('rabbit-buff', this.onChangeBuffStatus, this)
}
removeEvents(): void {
this.removeEventListener(FYGE.MouseEvent.MOUSE_UP, this.onTouchUp, this)
this.removeEventListener(FYGE.MouseEvent.MOUSE_DOWN, this.onTouchStart, this)
this.removeEventListener(FYGE.Event.ENTER_FRAME, this.onUpdate, this)
GDispatcher.removeEventListener('update-score', this.onUpdateScore, this)
GDispatcher.removeEventListener('show-radish', this.onShowRadishTips, this)
GDispatcher.removeEventListener('game-over', this.onGameOver, this)
GDispatcher.removeEventListener('rabbit-buff', this.onChangeBuffStatus, this)
}
/**
* 更新score
* @param e
*/
onUpdateScore(e) {
console.log(e.data)
this.score += e.data.score
}
onTouchStart(e) {
if (!this.GameStatus) return
this.touchStartX = e.clientX
this.stage.addEventListener(FYGE.MouseEvent.MOUSE_MOVE, this.onTouchMove, this)
this.stage.once(FYGE.MouseEvent.MOUSE_UP, function() {
this.stage.removeEventListener(FYGE.MouseEvent.MOUSE_MOVE, this.onTouchMove)
}, this)
}
onTouchUp(e) {
if (!this.touchStartX) return
const a = e.clientX - this.touchStartX
this.currRabbitIndex += (e.clientX - this.touchStartX > 0 ? 1 : -1) * (Math.abs(e.clientX - this.touchStartX) > 100 ? 1 : 0)
this.touchStartX = null
}
onTouchMove(e) {
// console.log(e.stageX, e.stageY)
// this.Rabbit.position.set(e.stageX, e.stageY)
}
onCollsion(c1: FYGE.Container,c2: FYGE.Container) {
if (!c1 || !c2) return false
const con1 = this.getCollsionGameEleData(c1)
const con2 = this.getCollsionData()
const abs = Math.abs
if (abs(con1.x - con2.x) < (con1.width + con2.width) / 2 && abs(con1.y - con2.y) < (con1.height + con2.height) / 2 ) {
return true
}
return false
}
/**
* 游戏兔子
* @param cont
* @returns
*/
getCollsionData() {
const h = 330
return {
x: this.rabbitPosXList[this.currRabbitIndex],
y: RabbitPos.y + 3 * h / 4,
width: 228,
height: h / 4
}
}
getCollsionGameEleData(cont: FYGE.Container) {
const h = cont.height
return {
x: cont.x - cont.width / 2,
y: cont.y - cont.height / 2 + 3 * h / 4,
width: cont.width,
height: cont.height / 4
}
}
TweenList: Array<any> = []
onTween2Rabbit = (ge: GameEle) => {
const rabbitData = this.getCollsionData()
FYGE.Tween.get(ge).to({
x: rabbitData.x + rabbitData.width / 2,
y: rabbitData.y + rabbitData.height / 2
}, 300).call(() => {
this.onGameEleCollision(ge)
// spliceArrItem(this.TweenList, ge)
})
// this.TweenList.push(ge)
}
onGameEleCollision(item: GameEle) {
item.parent.setChildIndex(item, 1)
item.onCollision()
item.visible = false
FYGE.Tween.removeTweens(item)
GPool.takeIn(item['_resType'], item)
}
onUpdate() {
if (!this.GameStatus) return
for (let i = 0; i < this.conveyorList.length; i++) {
const items = this.conveyorList[i].conveyorItems
for (const item of items) {
if (item._resType2 && this.GameStatus == 2 && item.y >= RabbitPos.y - 100) {
this.conveyorList[i].popConveyorItems(item)
this.onTween2Rabbit(item)
} else {
const flag = this.onCollsion(item, this.RabbitCont)
if (flag) {
this.conveyorList[i].popConveyor(item, true)
}
}
}
}
}
}
\ No newline at end of file
export const RabbitPos = {
y: 1100
}
export const GameCfg = {
totalTime: 3000,
radishTime: 5000
}
\ No newline at end of file
import { showToast } from './../../module/ctrls/toastCtrl';
import { changeScene } from './../../module/ctrls/index';
import { layers } from './../../module/views/layers';
import { Scene } from "../../module/views/Scene";
import UI from "../UI";
import { RES } from '../../module/RES';
import { GDispatcher } from '../Main';
import { GameScene, RadishCountDown } from './GameScene/GameScene';
import { getTbData, sendTbNet, TbNetName } from '../TaoBaoNet';
import CircleProgressBar from '../common/CircleProgressBar';
import { LOG_TYPE, sendLog } from '../WebNet';
export const IndexSceneConfig = {
ms: false
}
export default class IndexScene extends Scene {
startBtn: FYGE.Button
backBtn: FYGE.Sprite
ruleBtn: FYGE.Sprite
musicBtn: FYGE.Button
_ms: boolean // 音乐状态
indexSceneData: any
get groupNames(): string[] {
return ['IndexScene', 'svga']
}
get ms() {
return this._ms
}
set ms(v) {
this._ms = v
this.onMusicOperation(v)
return
}
initUi() {
this.indexSceneData = getTbData(TbNetName.doIndex).data
UI.Sp(this, 'index-scene-back.png')
const ani = this.addChild(new FYGE.MovieClip(RES.getRes('首页兔子.svga')))
ani.position.set(0, 0)
this.addChild(new FYGE.MovieClip(RES.getRes('首页背景动画.svga')))
const startBtnCont = UI.Ctn(this, 0, 1270)
this.startBtn = UI.Btn(startBtnCont, 'start-btn.png')
this.startBtn.position.set((750-this.startBtn.width) / 2, 0)
this.backBtn = UI.Sp(this, 'index_back_btn.png', 0, 250)
this.ruleBtn = UI.Sp(this, 'index_rule_btn.png', 0, 250)
this.ruleBtn.x = 750 - this.ruleBtn.width
this.musicBtn = UI.Btn(this, 'index_sound_on.png')
this.musicBtn.position.set(750 - this.musicBtn.width - 10, 310)
// var c = this.addChild(new RadishCountDown(5000))
// c.position.set(690, 370)
this.ms = IndexSceneConfig.ms
}
start(data?: any): void {
super.start()
sendLog(LOG_TYPE.EXPOSURE, 74)
sendTbNet(TbNetName.judgeLogin)
sendTbNet(TbNetName.indexSceneVisible, {visible: true})
}
initEvents(): void {
this.startBtn.addEventListener(FYGE.MouseEvent.CLICK, this.onGameStart, this)
this.musicBtn.addEventListener(FYGE.MouseEvent.CLICK, this.onMusicChangeStatus, this)
this.ruleBtn.addEventListener(FYGE.MouseEvent.CLICK, this.onRuleShowPanel, this)
this.backBtn.addEventListener(FYGE.MouseEvent.CLICK, this.onBackActivity, this)
}
async onGameStart() {
sendLog(LOG_TYPE.CLICK, 74)
if (this.indexSceneData.skiingGuideFlag == 0) {
const {success: s} = await sendTbNet(TbNetName.checkGameNum)
if (!s) {
showToast('游戏次数不足')
return
}
sendTbNet(TbNetName.indexSceneVisible, {visible: false})
if ( this.indexSceneData.skiingGuideFlag == 0 ) {
changeScene(GameScene, {
isNewGuy: true
})
} else {
}
} else {
const { success, data } = await sendTbNet(TbNetName.doStart)
if (success) {
sendTbNet(TbNetName.indexSceneVisible, {visible: false})
changeScene(GameScene, {
isNewGuy: false,
haveRadish: data.haveRadish
})
}
}
}
onRuleShowPanel() {
sendTbNet(TbNetName.showRuleModal, {
ruleText: getTbData(TbNetName.doIndex).data.gameRuleDesc
})
}
onBackActivity() {
sendTbNet(TbNetName.back)
}
onMusicChangeStatus() {
this.ms = !this.ms
}
onMusicOperation(v: boolean) {
this.musicBtn.texture = RES.getRes(v ? 'index_sound_on.png' : 'index_sound_off.png')
IndexSceneConfig.ms = v
if (v) {
sendTbNet(TbNetName.turnBgm, {
play: v
})
} else {
sendTbNet(TbNetName.turnBgm, {
play: v
})
}
}
}
\ No newline at end of file
import { RES } from '../../../module/RES';
import Clock from '../../Clock';
import { GDispatcher } from '../../Main';
import { getRandomNum, spliceArrItem } from '../../utils/utils';
import { GPool } from './../../../module/tools/GPool';
import { GameDiffConfig, GameEleOfBucket, GameEleOfPowerBall, GameEleOfWater } from './GameEle';
import { Pos } from "./GameTypes";
interface ConveyorBeltInfer {
start: Pos,
end: Pos,
obstacleWey?: () => boolean, // 障碍物出来的逻辑
obstacleJudge?: (item: FYGE.Container, con: ConveyorBelt) => void, // 障碍物 处理判断
updateScore?: (score: number) => void // 更新分数
}
type ConveyorBeltItemConstruct = GameEleOfBucket | GameEleOfWater | GameEleOfPowerBall
type ConveyorItemResName = string
type ConveyorBeltItemType = {
construct: any,
resName: ConveyorItemResName,
isObstacle?: boolean
}
// 默认升序
const ConveyorBeltItemList: Array<ConveyorBeltItemType> = [
{
construct: GameEleOfPowerBall,
resName: 'powerBall.svga',
isObstacle: false
},
{
construct: GameEleOfWater,
resName: 'water_GE.png',
isObstacle: true
},
{
construct: GameEleOfBucket,
resName: 'bucket_GE.png',
isObstacle: true
}
]
type ConveyorItemConfig = {
conveyorItemsList: Array<ConveyorBeltItemType>,
isRandom: boolean
}
const defaultConveyorConfig:ConveyorItemConfig = {
conveyorItemsList: ConveyorBeltItemList,
isRandom: true
}
export class ConveyorBelt extends FYGE.Container {
startPos: Pos
endPos: Pos
obstacleWey?: () => boolean
obstacleJudge?: Function
_speed: number = 300 // 当前速度
spl: number // 下一个 出现的 距离 后面就去取 随机值
tanValue: number
totalDisY: number // 全部距离
ty: number = 0 // y 经历的距离
isMove: boolean = false // 是否已经开始
clock: Clock
conveyorItems: Array<ConveyorBeltItemConstruct> = []
scaleEndProportion: number = 0.5
_config: ConveyorItemConfig
totalTy: number = 0 // 一共走了多少距离 计算分数
updateScore: Function
get speed() {
return GameDiffConfig.getCurrGameDiff(this.getScore()).speed
}
constructor(props: ConveyorBeltInfer, splt?: number, config: ConveyorItemConfig = defaultConveyorConfig) {
super()
this.spl = splt || getRandomNum(0, 300)
this._config = config
this.clock = new Clock()
this.startPos = props.start
this.endPos = props.end
this.obstacleWey = props.obstacleWey
this.obstacleJudge = props.obstacleJudge
this.updateScore = props.updateScore
this.tanValue = Math.abs(props.start.x - props.end.x) ? (props.start.y - props.end.y) / (props.start.x - props.end.x) : 0
this.totalDisY = Math.abs(props.start.y - props.end.y)
this.initEvents()
}
reStart() {
this.conveyorItems.forEach(i => {
this.popConveyor(i)
})
this.start()
}
start() {
this.isMove = true
this.totalTy = 0
this.clock.restart()
}
stop() {
this.isMove = false
}
initEvents() {
this.addEventListener(FYGE.Event.ENTER_FRAME, this.onUpdate, this)
}
removeEvents() {
this.removeEventListener(FYGE.Event.ENTER_FRAME, this.onUpdate, this)
}
destroy(): void {
super.destroy()
GPool.clear()
this.removeEvents()
}
onInitConveyorItem(e: ConveyorBeltItemType) {
let item: ConveyorBeltItemConstruct
item = GPool.takeOut<ConveyorBeltItemConstruct>(e.resName) || new e.construct(e.resName)
// if (e.resName === 'bucket_GE.png') {
// } else if (e.resName === 'powerBall.svga') {
// item = GPool.takeOut<GameEleOfPowerBall>(e.resName) || new GameEleOfPowerBall(e.resName)
// } else if (e.resName === 'water_GE.png') {
// item = GPool.takeOut<GameEleOfWater>(e.resName) || new GameEleOfWater(e.resName)
// }
item.setPostion(this.startPos.x, this.startPos.y)
item.scale.set(0)
item.visible = true
this.conveyorItems.push(item)
return item
}
setNextSpl(n: number) {
this.spl = n
}
getNext = (() => {
let i = 0
return (isPowerBall: boolean = false) => {
if (this._config.isRandom) {
if (isPowerBall) {
return this._config.conveyorItemsList[0]
}
const p = Math.random()
const currDiff = GameDiffConfig.getCurrGameDiff(this.getScore()).proportion
// this._config.conveyorItemsList
const r = currDiff.findIndex((n: number) => {
return p < n
})
return this._config.conveyorItemsList[r]
} else {
const len = this._config.conveyorItemsList.length
return this._config.conveyorItemsList[i++%len]
}
}
})()
onRenderConveyorItem() {
let con: ConveyorBeltItemConstruct
if (this.obstacleWey) {
con = this.onInitConveyorItem(this.getNext(this.obstacleWey()))
} else {
con = this.onInitConveyorItem(this.getNext())
}
this.addChild(con)
}
/**
* 获取分数
*/
getScore() {
return Math.floor(this.totalTy / 10)
}
onChangePosByY(changeY: number) {
this.ty += changeY
this.totalTy += changeY
this.updateScore && this.updateScore(this.getScore())
if (this.ty >= this.spl) {
this.ty = 0
this.onRenderConveyorItem()
}
this.conveyorItems.forEach(target => {
if (!this.tanValue) {
} else {
target.x += changeY / this.tanValue
}
target.y += changeY
const yp = changeY / (this.totalDisY * this.scaleEndProportion)
// target.alpha += yp
target.scaleX < 1 && (target.scaleX += yp);
target.scaleX < 1 && (target.scaleY += yp);
if (target.y >= this.endPos.y) {
this.popConveyor(target)
}
this.obstacleJudge && this.obstacleJudge(target, this)
})
// if (target.y >= RabbitPos.y + 200) {
// this.ConveyorBeltConfigData.onBehindFromRabbit(target)
// }
}
// 因为碰撞或者移动出去的 销毁
popConveyor(item: ConveyorBeltItemConstruct, didu?: boolean) {
if (didu) {
item.onCollision()
}
item.visible = false
spliceArrItem(this.conveyorItems, item)
GPool.takeIn(item._res, item)
}
onUpdate() {
if (!this.isMove) return
const diff = this.clock.getDelta()
if (diff > 0.1) return
const currSpeed = this.speed
this.onChangePosByY(diff * currSpeed)
}
}
\ No newline at end of file
import { RES } from "../../../module/RES"
import { Tools } from "../../Tools";
import UI from "../../UI";
import { CollisionData } from "./GameTypes"
interface CurrProportion {
mileage: number,
proportion: Array<number>,
speed: number
}
type ProportionList = Array<CurrProportion>
type GameDiffConfigType = {
initGameDiff: Function,
getCurrGameDiff: Function
}
export const GameDiffConfig: GameDiffConfigType = (function() {
let proportionList:ProportionList = []
return {
initGameDiff(pl: ProportionList) {
proportionList = pl || [
{
mileage: 100,
proportion: [0.5,0.7,1],
speed: 300,
},
{
mileage: 120,
proportion: [0.5,0.7,1],
speed: 330,
},
{
mileage: 200,
proportion: [0.1,0.7,1],
speed: 500,
}
]
},
/**
* 获取当前 概率
* @param m
*/
getCurrGameDiff(m: number):CurrProportion {
const currIndex = proportionList.findIndex(i => m < i.mileage)
// console.log(currIndex, proportionList, proportionList.slice(currIndex, 1))
const curr = currIndex == -1 ? proportionList.slice(-1)[0] : proportionList[currIndex]
return curr
}
}
})()
/**
* obstacle 障碍物 unObstacle 非障碍物
*/
export type GameEleType = 'obstacle' | 'unObstacle'
interface GameEleInfer {
_type: GameEleType,
_res: string,
getMaterialCollisionObj: () => CollisionData, // 获取碰撞
setPostion: (x: number, y: number) => void // 配置坐标
onCollision: () => void
}
interface GameEleOfGamerPropsInfer {
isSpeedUp: boolean
}
export class GameEleOfGamer extends FYGE.Container implements GameEleInfer {
_type: GameEleType = 'obstacle'
_res: string;
_isSpeedUp: boolean = false
offsetX: number = 120
offsetY: number = 230
collisionProportionOfY: number = 0.2
rWidth: number = 260
rHeight: number = 460
pxl: Array<number> = [0, 360, 750]
_pxlIndex: number = 1
GamerMovieClip: FYGE.MovieClip
protectAtomphere: FYGE.Sprite
status: number = 0 // 0 正常 1 闪烁
isStart: boolean = false
get isSpeedUp() {
return this._isSpeedUp
}
set isSpeedUp(n) {
if (!n) {
this.protectAtomphere && (this.protectAtomphere.visible = false);
(this.GamerMovieClip || (this.GamerMovieClip = this.GamerMovieClip = UI.MoiveClip(this, 'normalGamer.svga', -40))).init(RES.getRes('normalGamer.svga'))
} else {
(this.protectAtomphere || (this.protectAtomphere = UI.Sp(this, 'gamer-protect.png', -210, -150))).visible = true;
FYGE.Tween.get(this.protectAtomphere, {
loop: true
})
.to({alpha: 0.6}, 600)
.to({alpha: 1}, 600)
this.GamerMovieClip.init(RES.getRes('speedUpGamer.svga'))
}
this._isSpeedUp = n
}
get pxlIndex():number {
return this._pxlIndex
}
set pxlIndex(n) {
if (this.pxl[n] === undefined) {
return
}
FYGE.Tween.removeTweens(this)
const tr = Math.abs(this.pxl[n] - this.fx) / 360 * 200
FYGE.Tween.get(this)
.to({
fx: this.pxl[n]
}, tr)
this._pxlIndex = n
}
get fx() {
return this.x + this.offsetX
}
set fx(n) {
this.x = n - this.offsetX
}
get fy() {
return this.y + this.offsetY
}
set fy(n) {
this.y = n - this.offsetY
}
constructor(props:GameEleOfGamerPropsInfer) {
super()
this.isSpeedUp = props.isSpeedUp
this.initUi()
this.stop()
}
start() {
this.GamerMovieClip?.play()
}
stop() {
this.GamerMovieClip?.stop()
}
reset() {
this.pxlIndex = 1
this.fy = 1130
}
/**
* 设置左右移动, +1 或者 -1
* @param n
*/
setGamerPosIndex(n: number) {
this.pxlIndex += n
console.log('test:', this.pxlIndex, n)
}
initUi() {
// 240 1000
Tools.PAGE.debug && UI.Rect(this, 260, this.rHeight * this.collisionProportionOfY, 0xcccccc, 20, 0, this.rHeight * (1-this.collisionProportionOfY)-50, 0.7)
this.reset()
}
setPostion(x: number, y: number=1130) {
this.fx = x
this.fy = y
// this.position.set(x - this.offsetX, y - this.offsetY)
}
getMaterialCollisionObj(): CollisionData {
return {
x: this.x,
y: this.y + this.rHeight * (1 - this.collisionProportionOfY)-50,
w: this.rWidth,
h: this.rHeight * this.collisionProportionOfY
}
}
onBulingBuling() {
if (this.status) return
this.status = 1
FYGE.Tween.get(this, {
loop: true
})
.to({alpha: 0.6}, 200)
.to({alpha: 1}, 200)
setTimeout(() => {
FYGE.Tween.removeTweens(this)
this.alpha = 1
this.status = 0
}, 2000)
}
onCollision() {}
}
export class GameEleOfPowerBall extends FYGE.Container implements GameEleInfer {
_type: GameEleType = 'unObstacle'
_res: string
offsetX: number = 130
offsetY: number = 130
collisionProportionOfY: number = 0.4
rHeight: number = 260
rWidth: number = 260
/**
* 基本比较是200*200的大小
* @param mv
* @param whInfo
*/
constructor(mv: string) {
super()
this.addChild(new FYGE.Sprite(RES.getRes('powerBallShadow.png')))
.position.set(90, 260)
this.addChild(new FYGE.MovieClip(RES.getRes(mv)))
this._res = mv
this.anchor.set(this.offsetX, this.offsetY)
const t = this.getMaterialCollisionObj()
Tools.PAGE.debug && UI.Rect(this, t.w, t.h, 0xcccccc, 20, 0, this.rHeight * (1-this.collisionProportionOfY), 0.7)
}
setPostion(x: number, y: number=0) {
this.position.set(x - this.offsetX, y - this.offsetY)
}
onCollision() {
}
getMaterialCollisionObj(): CollisionData {
return {
x: this.x,
y: this.y + this.rHeight * (1 - this.collisionProportionOfY),
w: this.rWidth,
h: this.rHeight * this.collisionProportionOfY
}
}
}
export class GameEleOfWater extends FYGE.Sprite implements GameEleInfer {
_type: GameEleType = 'obstacle'
_res: string
collisionProportionOfY: number = 0.5
constructor(res: string) {
super(RES.getRes(res))
this._res = res
this.anchorTexture.set(0.5, 0.5)
const t = this.getMaterialCollisionObj()
Tools.PAGE.debug && UI.Rect(this, t.w, t.h, 0xcccccc, 20, 0 - this.width / 2, this.height * (1-this.collisionProportionOfY) - this.height / 2, 0.7)
}
setPostion(x: number, y: number=0) {
this.position.set(x, y)
}
getMaterialCollisionObj():CollisionData {
return {
x: this.x - this.width / 2,
y: this.y - this.height / 2 + this.height * (1 - this.collisionProportionOfY),
w: this.width,
h: this.height * this.collisionProportionOfY
}
}
onCollision() {
}
reset() {
}
}
export class GameEleOfBucket extends FYGE.Sprite implements GameEleInfer {
_type: GameEleType = 'obstacle'
_res: string
collisionProportionOfY: number = 0.4
constructor(res: string) {
super(RES.getRes(res))
this._res = res
this.anchorTexture.set(0.5, 0.5)
const t = this.getMaterialCollisionObj()
Tools.PAGE.debug && UI.Rect(this, t.w, t.h, 0xcccccc, 20, 0- this.width / 2, this.height * (1-this.collisionProportionOfY) - this.height / 2, 0.7)
}
setPostion(x: number, y: number=0) {
this.position.set(x, y)
}
onCollision() {
}
getMaterialCollisionObj():CollisionData {
return {
x: this.x - this.width / 2,
y: this.y - this.height / 2 + this.height * (1 - this.collisionProportionOfY),
w: this.width,
h: this.height * this.collisionProportionOfY
}
};
}
\ No newline at end of file
export interface Pos {
x: number,
y: number
}
export interface CollisionData extends Pos {
w: number,
h: number
}
export interface MaterialBaseInfo {
w: number,
h: number
}
import { ConveyorBelt } from './ConveyorBelt';
import { GameEleOfPowerBall, GameEleOfWater, GameEleOfBucket, GameEleOfGamer } from './GameEle';
import UI from '../../UI';
import { Scene } from './../../../module/views/Scene';
import { RES } from '../../../module/RES';
import { collisionJudge, SetMouseEventNone } from '../../utils/utils';
import { leftBanner } from '../../lotties/leftBanner';
import { rightBanner } from '../../lotties/rightBanner';
import { banner1 } from '../../lotties/banner1';
import { banner2 } from '../../lotties/banner2';
import { ProgressBarS } from '../../common/ProgressBarS';
import { Tools } from '../../Tools';
import { getTbData, sendTbNet, TbNetName } from '../../TaoBaoNet';
const hpPoxLis = [55, 82, 109]
export class PowerProgress extends FYGE.Container {
_value: number = 0
progress: ProgressBarS
fullFunc?: Function
status: number = 0 // 0 正常 1 动效
get value() {
return this._value
}
set value(n) {
if (n > 1) n = 1
if (n < 0) n = 0
this._value = n
FYGE.Tween.removeTweens(this.progress)
FYGE.Tween.get(this.progress)
.to({
value: n
}, 100)
if (n == 1 && !this.status) {
this.powerFullAni(true)
}
}
/**
* 进度条满的时候 逻辑
* @param f
*/
constructor(f?: Function) {
super()
this.fullFunc = f || (() => {})
this.initUi()
}
add() {
if (!this.status) {
this.value += 0.1
}
}
speedShow: FYGE.MovieClip
powerFullAni(b: boolean = true) {
if (b && this.status == 0) {
this.status = 1
this.fullFunc(true);
(this.speedShow || (this.speedShow = UI.MoiveClip(this, 'speedShow.svga', -30, -30))).visible = true;
FYGE.Tween.get(this)
.to({value: 0}, 5000)
.call(() => {
this.fullFunc(false)
this.powerFullAni(false)
this.status = 0
})
} else {
this.speedShow.visible = false
}
}
initUi() {
UI.Sp(this, 'powerProgress-back.png')
var p = this.progress = new ProgressBarS(UI.Sp(this, 'powerProgress-p.png', 28, 52), null, 'top')
p.value = 0
UI.Sp(this, 'powerProgress-logo.png')
}
}
class NewGuyScene extends FYGE.Container {
finishFunc: Function
constructor(finishFunc: Function) {
super()
this.finishFunc = finishFunc
this.initUi()
}
gs: FYGE.Sprite
step: number = 1
initUi() {
this.gs = UI.Sp(this, 'Guide1.png')
this.addEventListener(FYGE.MouseEvent.CLICK, this.nextStep, this)
}
nextStep() {
this.step += 1
if (this.step == 4) {
this.finishFunc()
this.destroy()
return
}
this.gs.texture = RES.getRes(`Guide${this.step}.png`)
}
destroy(): void {
super.destroy()
this.removeAllEventListener()
}
}
export class LevonoGameScene extends Scene {
conveyorList: Array<ConveyorBelt> = []
besidesList: Array<ConveyorBelt> = []
_GameStatus: number // 0 未开始 1 倒计时 2开始游戏 3 玩家 开始加速
Gamer: GameEleOfGamer
powerPro: PowerProgress
_hp: number = 3
hpSpriteList: Array<FYGE.Sprite> = []
atomList: Array<FYGE.Container> = []
_musicStatus: boolean = false
musicBtn: FYGE.Button
_score: number = 0
scoreBitMapText: FYGE.BitmapText
get score() {
return this._score
}
set score(s) {
this.scoreBitMapText.text = `${s}m`
this._score = s
}
get musicStatus() {
return this._musicStatus
}
set musicStatus(b) {
(this.musicBtn || (this.musicBtn = UI.Btn(this, `music-${b ? 'on' : 'off'}.png`, this.musicBtnClick, this,
670, 200
))).texture = RES.getRes(`music-${b ? 'on' : 'off'}.png`)
this.playSoundById('bgm', b, true, true)
this._musicStatus = b;
}
get GameStatus() {
return this._GameStatus
}
set GameStatus(n) {
if (n === this._GameStatus) return
this._GameStatus = n
}
get hp() {
return this._hp
}
set hp(n) {
for (var i = 0; i < 3; i ++) {
this.hpSpriteList[i].visible = i < n
}
this._hp = n
if (!n) {
this.GameStatus = 0
this.onGameOver()
}
}
get groupNames(): string[] {
return [
'LevonoGameScene',
'LevonoSvga',
'banner1',
'banner2'
]
}
musicBtnClick() {
this.musicStatus = !this.musicStatus
}
playSoundById(id: string, isOn: boolean = true, loop:boolean = false, force: boolean = false) {
if (!this.musicStatus && !force) return
sendTbNet(TbNetName.turnBgm, {
id: id,
loop: loop,
play: isOn
}, null, true, true)
}
initUi() {
UI.Sp(this, 'scene-back.jpg')
this.atomList.push(SetMouseEventNone(UI.MoiveClip(this, 'mountain.svga',30, 280)))
this.atomList.push(SetMouseEventNone(UI.MoiveClip(this, 'tree.svga', -10, 430)))
// SetMouseEventNone(UI.MoiveClip(this, 'leftBanner.svga',0, 450))
// SetMouseEventNone(UI.MoiveClip(this, 'rightBanner.svga', 420, 450))
this.atomList.push(SetMouseEventNone(UI.Lottie(this, banner1, 0, 450)))
this.atomList.push(SetMouseEventNone(UI.Lottie(this, banner2, 420, 450)))
// this.addChild(new GameEleOfWater(RES.getRes('water_GE.png')))
// this.addChild(new GameEleOfBucket(RES.getRes('bucket_GE.png')))
// var ball = this.addChild(new GameEleOfPowerBall(RES.getRes('powerBall.svga')))
// ball.setPostion(130, 130)
// ball.scale.set(0.5, 0.5)
// UI.Rect(this, 260, 460, 0xcccccc, 20, 240, 1000, 0.7)
this.conveyorList.push(this.addChild(new ConveyorBelt({
start: {
x: 358,
y: 510,
},
end: {
x: -300, y: 1624
},
obstacleWey: this.shouldOutObstacle,
obstacleJudge(t, con) {
con.setNextSpl(300 + Math.random() * 300)
}
})))
this.conveyorList.push(this.addChild(new ConveyorBelt({
start: {
x: 380,
y: 510,
},
end: {
x: 355, y: 1624
},
obstacleWey: this.shouldOutObstacle,
obstacleJudge(t, con) {
con.setNextSpl(300 + Math.random() * 300)
}
})))
this.conveyorList.push(this.addChild(new ConveyorBelt({
start: {
x: 402,
y: 510,
},
end: {
x: 1050, y: 1624
},
obstacleWey: this.shouldOutObstacle,
obstacleJudge(t, con) {
con.setNextSpl(300 + Math.random() * 300)
},
updateScore: this.updateScore
})))
// UI.MoiveClip(this, '障碍物.svga', 0, -5)
// UI.MoiveClip(this, '障碍物2.svga', 0, -5)
this.besidesList.push(this.addChild(new ConveyorBelt({
start: {
x: 412,
y: 510,
},
end: {
x: 1470, y: 1624
},
obstacleJudge(t, con) {
con.setNextSpl(100)
},
}, 0, {
conveyorItemsList: [
{
construct: GameEleOfWater,
resName: 'yellow_obstacle.png'
},
{
construct: GameEleOfWater,
resName: 'right_m.png'
},
{
construct: GameEleOfWater,
resName: 'red_obstacle.png'
},
{
construct: GameEleOfWater,
resName: 'right_m.png'
},
],
isRandom: false
})))
this.besidesList.push(this.addChild(new ConveyorBelt({
start: {
x: 348,
y: 510,
},
end: {
x: -740, y: 1624
},
obstacleJudge(t, con) {
con.setNextSpl(100)
},
}, 0, {
conveyorItemsList: [
{
construct: GameEleOfWater,
resName: 'yellow_obstacle0.png'
},
{
construct: GameEleOfWater,
resName: 'left_m.png'
},
{
construct: GameEleOfWater,
resName: 'red_obstacle0.png'
},
{
construct: GameEleOfWater,
resName: 'left_m.png'
},
],
isRandom: false
})))
this.Gamer = this.addChild(new GameEleOfGamer({
isSpeedUp: false
}))
// hpCOnt
const hpCont = UI.Ctn(this, 0, 200)
UI.Sp(hpCont, 'hpBoard-back.png')
for (let i = 0; i < hpPoxLis.length; i++) {
const x = hpPoxLis[i];
this.hpSpriteList.push(UI.Sp(hpCont, 'hpBoard-hp.png', x, 14))
}
this.powerPro = this.addChild(new PowerProgress(this.onGamerSpeedUp))
this.powerPro.position.set(30, 300)
const textureList = Tools.getNumTextures('score_')
textureList['m'] = RES.getRes('score_m.png')
const score = this.scoreBitMapText = this.addChild(new FYGE.BitmapText(textureList))
score.position.set(380, 260)
}
start(data?: any): void {
super.start()
this.GameStatus = 0
this.onGameStop()
if (data.isNewGuy) {
this.addChild(new NewGuyScene(async () => {
this.onGameRestart()
}))
return
}
this.onGameRestart()
// this.musicStatus = true
// setTimeout(() => {
// this.GameStatus = 1
// }, 500)
}
updateScore = (score: number) => {
this.score = score
}
ActiveFunc(func: Function, statusList: Array<number>, toast?:any) {
return (...args:any) => {
if (statusList.includes(this.GameStatus)) {
return func.apply(this, args)
} else {
}
}
}
async onGameRestart() {
const {success} = await sendTbNet(TbNetName.startGame)
if (!success) {
return
}
this.onGamePreStart()
}
/**
* 游戏前置处理
*/
onGamePreStart() {
this.musicStatus = Tools.PAGE.musicSwitchDefault
this.GameStatus = 1
this.score = 0
this.showAniCountDown()
}
CountDownSvga: FYGE.MovieClip
showAniCountDown() {
var s = (this.CountDownSvga || SetMouseEventNone(this.CountDownSvga = UI.MoiveClip(this, 'countDown.svga', 260, 600)));
s.visible = true
this.playSoundById('countDown')
s.startAniRange(0, s.totalFrames, 1, () => {
this.GameStatus = 2
this.onGameStart()
s.visible = false
})
}
onGamerSpeedUp = this.ActiveFunc((b: boolean) => {
this.GameStatus = b ? 3 : 2
if (b) {
this.Gamer.isSpeedUp = true
} else {
this.Gamer.isSpeedUp = false
}
}, [2, 3])
onGameStart() {
this.conveyorList.forEach(e => {
e.start()
})
this.besidesList.forEach(e => {
e.start()
})
// @ts-ignore
this.atomList.forEach(i => i.play && i.play())
this.Gamer.start()
}
onGameStop() {
this.conveyorList.forEach(e => {
e.stop()
})
this.besidesList.forEach(e => {
e.stop()
})
// @ts-ignore
this.atomList.forEach(i => i.stop && i.stop())
this.Gamer.stop()
}
async onGameOver() {
this.onGameStop()
const {success, data} = await sendTbNet(TbNetName.submitGame, {
score: this.score,
timestamp: Date.now(),
startId: getTbData(TbNetName.startGame).data.startId
})
}
initEvents(): void {
this.addEventListener(FYGE.MouseEvent.MOUSE_DOWN, this.onTouchStart, this)
this.addEventListener(FYGE.Event.ENTER_FRAME, this.onFrameUpdate, this)
}
removeEvents(): void {
this.removeAllEventListener()
}
touchStartX: number
onTouchStart(e) {
if ([0, 1].includes(this.GameStatus)) return
this.touchStartX = e.clientX
this.stage.once(FYGE.MouseEvent.MOUSE_UP, (e) => {
if (!this.touchStartX) return
const mx = e.clientX - this.touchStartX
this.Gamer.setGamerPosIndex((mx > 0 ? 1 : -1) * (Math.abs(mx) > 100 ? 1 : 0))
this.touchStartX = null
}, this)
}
/**
* 是否只出 能量
* @returns
*/
shouldOutObstacle = () => {
let b = this.conveyorList.filter(item => {
return item.conveyorItems.some(i => {
return i.y < 800 && i._type === 'obstacle'
})
}).length == 2
return b
}
onAddPower() {
this.playSoundById('powerSound')
this.GameStatus !== 3 && this.powerPro.add()
}
onReducePower() {
this.playSoundById('obstacleSound')
if (this.GameStatus !== 3) {
this.Gamer.onBulingBuling()
this.hp -= 1
}
}
onFrameUpdate() {
if (!this.GameStatus) return
for (let con of this.conveyorList) {
const items = con.conveyorItems
for ( let item of items ) {
if (item.y > 800) {
const isCollisioned = collisionJudge(this.Gamer.getMaterialCollisionObj(), item.getMaterialCollisionObj())
if (isCollisioned) {
if (item._type === 'obstacle') {
this.onReducePower()
} else {
this.onAddPower()
}
con.popConveyor(item)
item.onCollision && item.onCollision()
}
}
}
}
}
}
\ No newline at end of file
import { GameEle } from './../GameEle';
import UI from "../../UI"
import { SetMouseEventNode } from "../../utils/utils"
import { ConveyorBeltGameEle } from '../GameScene/ConveyorBeltConfig';
import { getTbData, TbNetName } from '../../TaoBaoNet';
export class NewGuyScene extends FYGE.Container {
currStep: number = 0
stepCont: FYGE.Container
finishFunc: Function
constructor(finishFunc?: Function) {
super()
this.finishFunc = finishFunc
this.initUi()
this.addStep()
this.initEvents()
}
initUi() {
this.stepCont = UI.Ctn(this, 0)
SetMouseEventNode(this.stepCont)
UI.Rect(this,750, 1624, 0xffffff, 0,0,0,0)
}
initEvents() {
this.addEventListener(FYGE.MouseEvent.CLICK, this.addStep, this)
}
removeEvents() {
this.removeEventListener(FYGE.MouseEvent.CLICK, this.addStep, this)
}
destroy(): void {
super.destroy()
this.removeEvents()
}
addStep() {
++this.currStep
this.stepCont.removeAllChildren()
switch (this.currStep) {
case 1:
UI.Sp(this.stepCont, 'guide1.png')
break;
case 2:
UI.Rect(this.stepCont, 750, 1624, 0x111111, 0, 0, 0, 0.7)
this.stepCont.addChild(new GameEle(ConveyorBeltGameEle[0]))
.position.set(130, 600)
this.stepCont.addChild(new GameEle(ConveyorBeltGameEle[1]))
.position.set(380, 580)
UI.Txt(this.stepCont, `+${getTbData(TbNetName.doIndex).data.skiingOneStarScore}`, 80, '#fcee68', FYGE.TEXT_ALIGN.LEFT, 200, 280, 640, true)
UI.Txt(this.stepCont, `+${getTbData(TbNetName.doIndex).data.skiingOneCardScore}`, 80, '#fcee68', FYGE.TEXT_ALIGN.LEFT, 200, 560, 640, true)
UI.Txt(this.stepCont, '收集冬奥卡和星星可增加得分', 30, '#ffffff', FYGE.TEXT_ALIGN.CENTER, 750, 0, 800)
break
case 3:
UI.Rect(this.stepCont, 750, 1624, 0x111111, 0, 0, 0, 0.7)
this.stepCont.addChild(new GameEle(ConveyorBeltGameEle[2]))
.position.set(290, 580)
UI.Txt(this.stepCont, '撞到障碍物游戏结束', 30, '#ffffff', FYGE.TEXT_ALIGN.CENTER, 750, 0, 800)
break
default:
this.finishFunc && this.finishFunc()
this.destroy()
break;
}
}
}
\ No newline at end of file
import { layers } from "../../module/views/layers";
import { CollisionData } from "../scenes/LevonoGameScene/GameTypes";
/**
* 函数防抖,如下拉菜单
......@@ -142,3 +143,28 @@ export function SetMouseEventNode(con: FYGE.Container) {
con.mouseChildren = false
con.mouseEnable = false
}
export function SetMouseEventNone<T extends FYGE.Container>(con: T):T {
con.mouseChildren = false
con.mouseEnable = false
return con
}
/**
* 获取 随机数
* @param min
* @param max
*/
export function getRandomNum(min:number, max: number) {
return Math.random() * (max - min) + min
}
export function collisionJudge(c1: CollisionData, c2: CollisionData) {
if (!c1 || !c2) return false
var con1 = c1, con2 = c2
const abs = Math.abs
if (abs(con1.x - con2.x) < (con1.w + con2.w) / 2 && abs(con1.y - con2.y) < (con1.h + con2.h) / 2 ) {
return true
}
return false
}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
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