Commit df359b61 authored by hahhh11's avatar hahhh11

改游戏为挑战

parent 361efa8a
{
"groups": [
{
"keys": "countdown-back.png",
"name": "CountDownComp"
},
{
"keys": "back-home.png,jump-icon.png,more-btn.png,new-record-icon.png,product-link__icon.png,share-btn.png",
"name": "GameOver"
},
{
"keys": "over-back.png,over-tipsicon.png,prize-icon1.png,prize-icon2.png,prize-icon3.png",
"name": "GameOverPanel"
},
{
"keys": "num0.png,num1.png,num2.png,num3.png,num4.png,num5.png,num6.png,num7.png,num8.png,num9.png,numb0.png,numb1.png,numb2.png,numb3.png,numb4.png,numb5.png,numb6.png,numb7.png,numb8.png,numb9.png,numbp.png,nump.png,p1-b.png,p10-b.png,p11-b.png,p12-b.png,p13-b.png,p14-b.png,p15-b.png,p16-b.png,p17-b.png,p18-b.png,p19-b.png,p2-b.png,p20-b.png,p3-b.png,p4-b.png,p5-b.png,p6-b.png,p7-b.png,p8-b.png,p9-b.png",
"name": "GameScene"
},
{
"keys": "confirm-btn-1.png,newcp-back.png",
"name": "NewCompletePanel"
},
{
"keys": "confirm-btn.png,prize-back-title.png,prize-back.png",
"name": "PrizeShowPanel"
},
{
"keys": "0538f9077d06efad323df05b04e7662e.png,0b5fa6df9b5a26d539e77c2608608d8b.png,0b8805ae-138d-4397-ba2e-78c631199ce0.png,12ec8054b8c348ae7d1e958d1cd2588a.png,1ca73db4-7b05-4b0e-a0fb-8b8554ade130.png,25a820fd42aef3ebf647fa8a8f1b6d97.png,28d56a3f5babaecfd5f73e5813945b5f.png,293052b6-b434-43d0-9ab8-28b6186bd5ca.png,29d49776-b18b-4c9d-a753-82aaaa888624.png,2cf13601-7f36-49cc-8699-2a212858725f.png,359747a74903ade247a702ed9b9229e1.png,39f071fb61eea4b15c28ee87f9a42ab9.png,41178870-b275-495b-8c72-9badb88d9f8c.png,4b8809c43f465d648d826696fa6f402a.png,56b3e456-868a-49a1-bef9-029dc148ed5a.png,6a6640c7-6455-4901-b39c-6b326a1bedbe.png,6e2c9e1567421038ba7a35d5acc53cd5.png,73d6a8ce-2d10-48c1-9d98-6e9b9edf14cb.png,7c52769b370035c2ed3d45c4575899f6.png,8bc5a36a8dbf1a26043a75b265b4b1eb.png,96c45192-0b3e-4bb9-a56b-c8a6f02efef1.png,a0f816ef-8021-4202-a478-1e5c05dde786.png,a92d32f9a8c52dcc79d0c99de311474e.png,ad8b5041-5fdb-4947-8b91-be70e6227ce9.png,adf0dae232a9ffa6a9ce1352a7360980.png,b280118e-fcdf-4d8f-b2fd-357bd153c425.png,b75f6509-258d-4058-8ddc-382c082e5cd7.png,b901f16e009de3b207787382b611a267.png,beaa8224-6905-4ced-96eb-4f89d5896199.png,c2d234e2-dea6-44fd-bdf7-58d932204772.png,c3192272-4150-4f33-8e76-110355f09831.png,ce491a6c44cb6e60d7cc705630d719e1.png,d44c0d0dbb74647e3d1f3114e89a18fa.png,d5a8f96f100df42fd094915c7e70f625.png,d9e2bfe5ede84f7f53e57e6796cb54b2.png,da8a31673c7f5b4c68f4d4dc44ba8faf.png,dc51d376-f884-45fa-a76f-ca96f2f4d028.png,df583b9d-9a9c-4f47-90f1-67bcfa9fb308.png,e2feb63adef7d65f3d56dc84d5b59e65.png,e68dfb4b-2a63-43f2-a476-7445d80a0853.png,f992a7bf1bceafbc97fece72e04bcea9.png,ffc1d98f-d69e-43b1-8554-315276aa1322.png",
"name": "balance_guidance"
......@@ -36,10 +12,26 @@
"keys": "centerCircle.png,comCloseBtn.png,com_light.png,count-start.png,count1.png,count2.png,count3.png,jordan-icon.png,music-off.png,music-on.png,nike-icon.png,percennt0.png,percennt1.png,percennt2.png,percennt3.png,percennt4.png,percennt5.png,percennt6.png,percennt7.png,percennt8.png,percennt9.png,percenntp.png,ruready.png,toastBg.png,waitingBg.png,waitingRot.png",
"name": "common"
},
{
"keys": "countdown-back.png",
"name": "CountDownComp"
},
{
"keys": "c9a24fed01170dc61854098b7f6e50af.png",
"name": "excellent_icon"
},
{
"keys": "back-home.png,jump-icon.png,more-btn.png,new-record-icon.png,product-link__icon.png,share-btn.png",
"name": "GameOver"
},
{
"keys": "over-back.png,over-tipsicon.png,prize-icon1.png,prize-icon2.png,prize-icon3.png",
"name": "GameOverPanel"
},
{
"keys": "num0.png,num1.png,num2.png,num3.png,num4.png,num5.png,num6.png,num7.png,num8.png,num9.png,numb0.png,numb1.png,numb2.png,numb3.png,numb4.png,numb5.png,numb6.png,numb7.png,numb8.png,numb9.png,numbp.png,nump.png,p1-b.png,p10-b.png,p11-b.png,p12-b.png,p13-b.png,p14-b.png,p15-b.png,p16-b.png,p17-b.png,p18-b.png,p19-b.png,p2-b.png,p20-b.png,p3-b.png,p4-b.png,p5-b.png,p6-b.png,p7-b.png,p8-b.png,p9-b.png",
"name": "GameScene"
},
{
"keys": "009ed41bfa913bd15c5dda62716e608c.png,02f26c4510df27a5acb8ce26b9c5b0ba.png,1d202725fd410588dfa8b3e1ccf810ce.png,2027bc3879e8f06799f1759fa914f426.png,245201acb5b065e60711e402277d4908.png,24cbb272ca0595390a65d16269acc141.png,28c9a63f6e33fbc7b7f9c51db5752ac9.png,32f6ae97f854c575c7130c9c2896a287.png,47d38d653cd78676a3ca3b4e7b6a7044.png,4fd8362250aa1555a1cb6352a10ac312.png,5cf06ed99e90cd0e4464cac6dbb29dc3.png,5d19c027ad8778f99a3f0950acdd2739.png,6c0fa5d1972318368c48f4c09418459d.png,71b5a61c46ec88c372180e56cbc0fb3d.png,722612e4c34ae14ba427382557a0c9cb.png,73ef3d3454a074c9decb1ecb7909105e.png,76d230aac3001933de45c949a9140889.png,77a0ae8dd94043602811479e935beafb.png,84f82a9ec12dd316f44382818fe0553c.png,9ac140216cfe3e2ba0c5f9dcb8de4856.png,a06938c7a7105be8ffd0e68c82527be5.png,a0f9249750bdd4bd9aa3f628c7f47c67.png,a3196dffd24bec4ceeb78c40e789411d.png,a811ad9246c54b177ae8c5a211ecbf02.png,a856a0dae3018ef19512f88849596579.png,addea92ee44e85d3b5c4ad97c67e0bbb.png,b7b9e7b3a43aff9ec5b46f0d253d69cc.png,ba494e2790eab1b74233301f7a6e68e2.png,bf2712c0db9cb0e2d408a529cd2421ec.png,bf3c7702119ae821578eb99c069617a3.png,c08f4c1bceb6c129da183349eaa18702.png,c111333453e0bb104a4c0d89c20c4472.png,c5aab24b86fe3182b1285f85eaec5bfe.png,ca3be215bf1c00d85f491a5ee971554f.png,cbb3cb0886f45f3e42e31b635ac2f13d.png,d024b2620af9a5f440a611167f596457.png,d77eb6d84abf89c0d276de9c598e4c58.png,d82e528b29ad71b09e0be5681959a789.png,db8bdb142b802b126523cfccf4d6a503.png,dfa3f688ec9fdd0a465f9417bd43ebf2.png,dfdbfa372b9183cb08d320aa3cc43a11.png,e0913099d595c5bc06c3d3daa62d2083.png,e1c091647a039b1c089709a81c4cd379.png,e3e8798120c483a49384a4fcc52c099c.png,e8b1bf3e159712ea403845a373fbf92e.png,f52e180cd79bcf8658830bc0c54942b9.png,f782b72f25909b59f23d0cad704f5eb4.png,ff5c46f42d987a67da838ff09c183a93.png",
"name": "guidan_360"
......@@ -48,10 +40,18 @@
"keys": "p1.png,p10.png,p11.png,p12.png,p13.png,p14.png,p15.png,p16.png,p17.png,p18.png,p19.png,p2.png,p20.png,p3.png,p4.png,p5.png,p6.png,p7.png,p8.png,p9.png",
"name": "jordan_eles"
},
{
"keys": "confirm-btn-1.png,newcp-back.png",
"name": "NewCompletePanel"
},
{
"keys": "p1.png,p10.png,p11.png,p12.png,p13.png,p14.png,p15.png,p16.png,p17.png,p18.png,p19.png,p2.png,p20.png,p3.png,p4.png,p5.png,p6.png,p7.png,p8.png,p9.png",
"name": "nike_eles"
},
{
"keys": "confirm-btn.png,prize-back-title.png,prize-back.png",
"name": "PrizeShowPanel"
},
{
"keys": "0272a464df7d9c1ca7bcd240ff5b6ff1.png,0339f8cec366210e1895bb822005f5ca.png,0471fa62dfb977981f0bbcbf03d5364c.png,0521db775413790e5754d0a359a26c05.png,056b70b501ad2bb9de96fe5a40ec244c.png,0960016b2a4b0945ae1a504cf05d58b5.png,1366e0dc8765778425bc3612c5a02991.png,16794fd2bb051adab7cf54b7e36d2c87.png,1cb1e4d2fa9e520728a397f33dc41e85.png,23a5d1a88f781623a16727e8defbe5f2.png,243da2df1403d966f345a1bf61310276.png,2592ff4846d8e05ea9280a9206b2b765.png,2b774e8e40d7eeb4f56565090fcf1a1f.png,3965e139993e5072b687ba1e944ae568.png,3d5139ce-fcfd-4604-b6da-282230f8afee.png,4947993d9e0c86dd197cab056f32b26e.png,4f7efec7932532041668f88e5eaa6485.png,55223ef0f41017b272998afbf097e11c.png,643f90f77b7858c5a54f1f2d2371a396.png,6a9d7e1fce8bc7e9b014add6ba3a40a6.png,6b5ba368fd1b35b4f7ae7d0941983b5f.png,6eab818514531d8dd0aff35576e834fe.png,70fcb05422163afdc827b4c7aa421932.png,7acaef1cbaa854fcc731bf08b137faaa.png,7f2a9fd9bb5aa175e606246dd843aed9.png,8e2a1bf2cfd857dae69edb9d70820e23.png,9e4c70df3c98f66fc402e0e5e64e1f0b.png,9f874f56586024e4c873b6237d027558.png,a2a8d4e441d527d8fbd8f1d1b6ec237d.png,a4e1f9ed07a40359eaf255394e272272.png,aef93a72f0db18e2c6fbc356d101bac0.png,b18be206e2cfcc766695779607b91e33.png,b7cc11169a1c2980ff1f543adc5e83fb.png,b9689750-84db-4dc3-9bba-70c6e86ff2ca.png,bbd780a01510cbc706a71d5f96f52dcb.png,c6d5f14a2986660aec470230367eb3d3.png,c78db3f7c109f9cf731d5045c4886854.png,c7d57022-9cec-4af2-bcb3-faf33977b271.png,c9cef93be7451b685edbd1fcd8f61732.png,ddde1ae50b039bf96ef7737d5708f7dd.png,e0c229e262c34b128c0f50ecac33369b.png,eb51f7d9-1919-48e8-8a5b-5e2ee8cf3075.png",
"name": "red_shoe"
......
This diff is collapsed.
......@@ -302,7 +302,7 @@ export const SkinJson = {
"y": 369,
"type": "text",
"props": {
"text": "游戏规则\n",
"text": "挑战规则\n",
"size": 74.03529,
"fillColor": "#000000",
"textAlpha": 1
......@@ -976,7 +976,7 @@ export const SkinJson = {
"y": 612,
"type": "text",
"props": {
"text": "游戏次数+xx",
"text": "挑战次数+xx",
"size": 43.48474,
"fillColor": "#ff5555",
"textAlpha": 1
......
......@@ -9,11 +9,11 @@ import { GDispatcher } from '../../Main';
export class GameOverScene extends Scene {
bitmapTextCount: FYGE.BitmapText
get groupNames():string[] {
get groupNames(): string[] {
return ['GameOver', 'GameScene']
}
constructor(...args:any) {
constructor(...args: any) {
super(...args)
}
......@@ -25,7 +25,7 @@ export class GameOverScene extends Scene {
} else {
icon.position.set(41, layers.stageOffsetY - 90 + 5 + layers.stageOffsetY)
}
this.y -= layers.stageOffsetY - 90
console.log(this.data)
var bitMapc = Tools.getNumTextures('num')
......@@ -33,7 +33,7 @@ export class GameOverScene extends Scene {
var bitmapTextCount = this.bitmapTextCount = this.addChild(new FYGE.BitmapText(bitMapc))
if (this.data.score <= 3) {
this.bitmapTextCount.textures = bitMapc2
}
}
if (!this.data.hideMusic) {
if (this.data.score > 3) {
await sendTbNet(TbNetName.openMusic, {
......@@ -42,26 +42,26 @@ export class GameOverScene extends Scene {
loop: false
}, null, null, true)
}
this.showNumberUp()
}
}
this.bitmapTextCount.position.set(layers.stageCenterX, 500)
// this.bitmapTextCount.text = this.data.score + ''
bitmapTextCount.text = '0'
var desc = UI.Ctn(this, 0, 700)
UI.Txt(desc, '本局连续完成', 40, '#111111', FYGE.TEXT_ALIGN.CENTER, layers.stageWidth, 0, 10, true)
UI.Txt(desc, '游戏结束', 40, '#757575', FYGE.TEXT_ALIGN.CENTER, layers.stageWidth, 0, 62, true)
UI.Txt(desc, '挑战结束', 40, '#757575', FYGE.TEXT_ALIGN.CENTER, layers.stageWidth, 0, 62, true)
this.data.isNewRecord && UI.Sp(desc, 'new-record-icon.png', 490, -30)
UI.Btn(this, 'share-btn.png', function() {
UI.Btn(this, 'share-btn.png', function () {
// @ts-ignore todo 分享
my && my.showSharePanel()
addData(2)
}, this, 45, 930)
UI.Btn(this, 'more-btn.png', function() {
UI.Btn(this, 'more-btn.png', function () {
this.btnDelay(this)
sendTbNet(TbNetName.addTrack, {
type: 'wildwoodmg:app_back'
......@@ -77,7 +77,7 @@ export class GameOverScene extends Scene {
}, this, 45, 1090)
var _s = UI.Sp(this, 'back-home.png', layers.stageCenterX, 1310)
_s.addEventListener(FYGE.MouseEvent.CLICK, function() {
_s.addEventListener(FYGE.MouseEvent.CLICK, function () {
this.btnDelay(this)
sendTbNet(TbNetName.addTrack, {
type: 'wildwoodmg:app_exit'
......@@ -94,12 +94,12 @@ export class GameOverScene extends Scene {
var isJordan = Tools.globalData.shopId == 10003
UI.Rect(bottomCont, layers.stageWidth, 130, 0xffffff)
UI.Sp(bottomCont, 'product-link__icon.png', 50, 25)
UI.Txt(bottomCont, `${isJordan ? 'Jordan女子商品': 'Nike瑜伽商品'}`, 24, '#111111', FYGE.TEXT_ALIGN.LEFT, 500, 160, 40, true)
UI.Txt(bottomCont, `${isJordan ? 'Jordan女子商品' : 'Nike瑜伽商品'}`, 24, '#111111', FYGE.TEXT_ALIGN.LEFT, 500, 160, 40, true)
UI.Txt(bottomCont, `${isJordan ? '让你充满活力和灵感' : '让你的体态更加健康'}`, 22, '#111111', FYGE.TEXT_ALIGN.LEFT, 500, 160, 70, true)
UI.Sp(bottomCont, 'jump-icon.png', 600, 40)
.addEventListener(FYGE.MouseEvent.CLICK, function() {
.addEventListener(FYGE.MouseEvent.CLICK, function () {
this.btnDelay(this)
addData(7)
// @ts-ignore
// sendTbNet(TbNetName.navigateToOutside, {
......@@ -107,7 +107,7 @@ export class GameOverScene extends Scene {
// })
my.call(
'navigateToOutside',
{url: this.data.productLink}, (res) => {
{ url: this.data.productLink }, (res) => {
sendTbNet(TbNetName.addTrack, {
type: 'wildwoodmg:navigateToOutSide',
isSuccess: res.success,
......@@ -118,11 +118,11 @@ export class GameOverScene extends Scene {
}, this)
}
}
showNumberUp() {
var o = { _score: 0}
var o = { _score: 0 }
var bitmapTextCount = this.bitmapTextCount
Object.defineProperty(o, 'score', {
configurable: true,
......@@ -130,7 +130,7 @@ export class GameOverScene extends Scene {
get() {
return o._score
},
set(n:number) {
set(n: number) {
o._score = n
bitmapTextCount.text = ~~n + ''
}
......@@ -142,7 +142,7 @@ export class GameOverScene extends Scene {
}
initEvents() {
GDispatcher.once('init-score', async function() {
GDispatcher.once('init-score', async function () {
if (this.data.score > 3) {
await sendTbNet(TbNetName.openMusic, {
isOn: true,
......@@ -150,7 +150,7 @@ export class GameOverScene extends Scene {
loop: false
}, null, null, true)
}
this.showNumberUp()
}, this)
}
......
......@@ -21,28 +21,28 @@ const Container = FYGE.Container
const TEXT_ALIGN = FYGE.TEXT_ALIGN
//二维向量定义
const Vector2 = function(x, y) { this.x = x; this.y = y; };
const Vector2 = function (x, y) { this.x = x; this.y = y; };
Vector2.prototype = {
// 辅助一个向量
copy: function() { return new Vector2(this.x, this.y); },
copy: function () { return new Vector2(this.x, this.y); },
// 向量的模()长度
length: function() { return Math.sqrt(this.x * this.x + this.y * this.y); },
length: function () { return Math.sqrt(this.x * this.x + this.y * this.y); },
sqrLength: function() { return this.x * this.x + this.y * this.y; },
sqrLength: function () { return this.x * this.x + this.y * this.y; },
// 向量的单位向量
normalize: function() { var inv = 1 / this.length(); return new Vector2(this.x * inv, this.y * inv); },
normalize: function () { var inv = 1 / this.length(); return new Vector2(this.x * inv, this.y * inv); },
// 相反向量
negate: function() { return new Vector2(-this.x, -this.y); },
negate: function () { return new Vector2(-this.x, -this.y); },
// 向量相加
add: function(v) { return new Vector2(this.x + v.x, this.y + v.y); },
add: function (v) { return new Vector2(this.x + v.x, this.y + v.y); },
// 向量相减
subtract: function(v) { return new Vector2(this.x - v.x, this.y - v.y); },
subtract: function (v) { return new Vector2(this.x - v.x, this.y - v.y); },
// 向量数量乘法
multiply: function(f) { return new Vector2(this.x * f, this.y * f); },
multiply: function (f) { return new Vector2(this.x * f, this.y * f); },
// 向量数量除法
divide: function(f) { var invf = 1 / f; return new Vector2(this.x * invf, this.y * invf); },
divide: function (f) { var invf = 1 / f; return new Vector2(this.x * invf, this.y * invf); },
// 向量的点乘(内机)dot
dot: function(v) { return this.x * v.x + this.y * v.y; }
dot: function (v) { return this.x * v.x + this.y * v.y; }
};
/**
......@@ -51,11 +51,11 @@ Vector2.prototype = {
* @param delay
* @returns
*/
function debounce(func: Function, delay=1000) {
function debounce(func: Function, delay = 1000) {
var timer = {
curr: null
}
var fn = function(...args) {
var fn = function (...args) {
var context = this
if (timer.curr) clearTimeout(timer.curr)
timer.curr = setTimeout(() => {
......@@ -80,7 +80,7 @@ type pos = {
}
function pos2Len(p1: pos, p2:pos):number {
function pos2Len(p1: pos, p2: pos): number {
return Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2))
}
......@@ -88,7 +88,7 @@ class RandomArray {
iarr: Array<any>
arr: Array<any>
get len():number {
get len(): number {
return this.arr.length
}
......@@ -113,7 +113,7 @@ class RandomArray {
return value
}
spliceValue(v:any) {
spliceValue(v: any) {
var i = this.arr.indexOf(v)
if (i == -1) return
this.arr.splice(i, 1)
......@@ -127,11 +127,11 @@ export class GameScene extends MotionInitScene {
scoreText: FYGE.TextField
_score: number
gameEle: GameEle
_gIndex: number = 1 // 游戏元素索引
_gIndex: number = 1 // 挑战元素索引
isJordan: boolean
arr_t: RandomArray = new RandomArray(Array.from(Array(20), (_, i) => ++i))
constructor(){
constructor() {
super()
}
......@@ -157,7 +157,7 @@ export class GameScene extends MotionInitScene {
this.scoreText = UI.Txt(this, '连续完成: ' + n, 40, '#111111', FYGE.TEXT_ALIGN.CENTER, layers.stageWidth, -8, layers.stageOffsetY + (getApp().isLarge ? (250 - 168) : 50))
this.scoreText.mouseEnable = false
}
this.scoreText.text = '连续完成: '+n
this.scoreText.text = '连续完成: ' + n
}
get score() {
......@@ -169,7 +169,7 @@ export class GameScene extends MotionInitScene {
super.initUi()
this.score = 0
var cdp = this.cdp = this.addChild(new CountDownComp(GameCfg.getInitTime()))
this.setChildIndex(this.cdp, 2)
this.cdp.addTimeoutFunc(onceFnc(() => {
......@@ -178,7 +178,7 @@ export class GameScene extends MotionInitScene {
DeviceMotion.instance.destory()
this.gameEle && this.gameEle.freeze()
FYGE.Tween.removeAllTweens()
var fail = UI.Lottie(this, yoga_fail,180, 290)
var fail = UI.Lottie(this, yoga_fail, 180, 290)
fail.play(1, () => {
// close bgm
sendTbNet(TbNetName.openMusic, {
......@@ -187,7 +187,7 @@ export class GameScene extends MotionInitScene {
loop: true,
force: true
}, null, null, true)
sendTbNet(TbNetName.addTrack, {
type: 'wildwoodmg:app_finish_game'
......@@ -199,13 +199,13 @@ export class GameScene extends MotionInitScene {
score: this.score
})
})
}))
cdp.position.set(layers.stageCenterX - 65, layers.stageOffsetY + (getApp().isLarge ? 170 : 120))
}
async initGame() {
GameCfg.initLevel()
......@@ -224,16 +224,16 @@ export class GameScene extends MotionInitScene {
}
async onSubmit(params) {
const {data, success, message} = await sendTbNet(TbNetName.submitGame, params)
const { data, success, message } = await sendTbNet(TbNetName.submitGame, params)
if (success) {
const {score, isNewRecord, productLink, isWinPrize, level, isCompleteTask} = data
const { score, isNewRecord, productLink, isWinPrize, level, isCompleteTask } = data
isCompleteTask && sendTbNet(TbNetName.addTrack, {
type: 'wildwoodmg:app_finish_task'
}, null, null, true)
if (level) {
//@ts-ignore
my && my.vibrateShort()
showPanel(GameOverPanel, data)
} else {
changeScene(GameOverScene, data)
......@@ -277,13 +277,13 @@ export class GameScene extends MotionInitScene {
}
export class GameEle extends Container {
rorate:number // 旋转角度
rorate: number // 旋转角度
vx = GameCfg.ispeed // 当前x速度, 有初速度
vy = GameCfg.ispeed // 当前y速度, 有初速度
accx:number = 0 // 当前x 加速度
accy:number = 0 // 当前 y加速度
lt:number = 0 // lastTime
resisteAcc:number = GameCfg.resisteAcc // 摩擦力加速度
accx: number = 0 // 当前x 加速度
accy: number = 0 // 当前 y加速度
lt: number = 0 // lastTime
resisteAcc: number = GameCfg.resisteAcc // 摩擦力加速度
k: number // 旋转角度和和中心点距离的系数
isIn: boolean // 是否在中心范围内
......@@ -296,7 +296,7 @@ export class GameEle extends Container {
* 是否固定在页面上
* @param cb 正中心的回调函数
*/
constructor(textureName: string ,fixedCenter: pos, cb?: Function) {
constructor(textureName: string, fixedCenter: pos, cb?: Function) {
super()
this.fixedCenter = fixedCenter
this.finishFunc = cb
......@@ -328,7 +328,7 @@ export class GameEle extends Container {
} else {
throw new Error('GameEle need a sprite')
}
var rotation = Math.floor(Math.random() * 181 + 180)
this.k = (rotation) / (pos2Len(this.fixedCenter, this))
this.correctCoordinate(true)
......@@ -343,16 +343,16 @@ export class GameEle extends Container {
var _roration = this.rotation
this.freeze()
FYGE.Tween.get(this)
.set({alpha:0, scaleX: 1.5,scaleY: 1.5, rotation: _roration - 90})
.to({alpha:1, scaleX: 1,scaleY: 1, rotation: _roration - 20}, 500)
.to({scaleX: .93,scaleY: .93,rotation: _roration}, 150)
.to({scaleX: 1,scaleY: 1,}, 150)
.set({ alpha: 0, scaleX: 1.5, scaleY: 1.5, rotation: _roration - 90 })
.to({ alpha: 1, scaleX: 1, scaleY: 1, rotation: _roration - 20 }, 500)
.to({ scaleX: .93, scaleY: .93, rotation: _roration }, 150)
.to({ scaleX: 1, scaleY: 1, }, 150)
.call(() => {
this.unfreeze()
})
}
correctCoordinate(isCorrectRoration:boolean = false) {
correctCoordinate(isCorrectRoration: boolean = false) {
var sw = this.sprite.width / 2
if (this.x > layers.stageWidth + layers.stageOffsetX - sw) {
this.x = layers.stageWidth + layers.stageOffsetX - sw
......@@ -424,7 +424,7 @@ export class GameEle extends Container {
this.accy = GameCfg.acc * Math.sin(e.beta)
}
setRotation(n:number) {
setRotation(n: number) {
this.sprite.rotation = n
}
......@@ -488,21 +488,21 @@ export class GameEle extends Container {
// 过去的时间
var pt = (nt - this.lt) / GameCfg.fpsScale
this.lt = nt
var ax = 0
if (Math.abs(this.vx)<0.2 && Math.abs(this.accx) < Math.abs(this.resisteAcc)) {
if (Math.abs(this.vx) < 0.2 && Math.abs(this.accx) < Math.abs(this.resisteAcc)) {
ax = 0
this.vx = 0
} else {
ax = this.accx + (this.vx >=0 ? -1 : 1) * this.resisteAcc
ax = this.accx + (this.vx >= 0 ? -1 : 1) * this.resisteAcc
}
var ay = 0
if (Math.abs(this.vy)<0.2 && Math.abs(this.accy) < Math.abs(this.resisteAcc)) {
if (Math.abs(this.vy) < 0.2 && Math.abs(this.accy) < Math.abs(this.resisteAcc)) {
ay = 0
this.vy = 0
} else {
ay = this.accy + (this.vy >=0 ? -1 : 1) * this.resisteAcc
ay = this.accy + (this.vy >= 0 ? -1 : 1) * this.resisteAcc
}
......@@ -512,12 +512,12 @@ export class GameEle extends Container {
this.x += this.vx * pt
this.y += this.vy * pt
if(Math.abs(this.accx)<.01 && Math.abs(this.vx)<0.2){
this.vx =0
if (Math.abs(this.accx) < .01 && Math.abs(this.vx) < 0.2) {
this.vx = 0
}
if(Math.abs(this.accy)<.01 && Math.abs(this.vy)<0.2){
this.vy =0
if (Math.abs(this.accy) < .01 && Math.abs(this.vy) < 0.2) {
this.vy = 0
}
this.correctCoordinate()
......@@ -529,5 +529,5 @@ export class GameEle extends Container {
super.update()
}
}
\ No newline at end of file
......@@ -30,11 +30,11 @@ const pow = Math.pow
* @param delay
* @returns
*/
function debounce(func: Function, delay=1000) {
function debounce(func: Function, delay = 1000) {
var timer = {
curr: null
}
var fn = function(...args) {
var fn = function (...args) {
var context = this
if (timer.curr) clearTimeout(timer.curr)
timer.curr = setTimeout(() => {
......@@ -54,7 +54,7 @@ export class MotionInitFunc extends Container {
type: number // 用来区分新手引导还是 首页
step1Mask: FYGE.Container
constructor(type: number, cb?:Function) {
constructor(type: number, cb?: Function) {
super()
this.type = type
this.initGame = cb
......@@ -63,13 +63,13 @@ export class MotionInitFunc extends Container {
init() {
this.maskCont = UI.Ctn(this, layers.stageOffsetX, layers.stageOffsetY)
UI.Rect(this.maskCont , 750, 1624, 0x1b1a1a, 0).alpha=0.8
UI.Rect(this.maskCont, 750, 1624, 0x1b1a1a, 0).alpha = 0.8
this.step1Mask = UI.Ctn(this.maskCont)
UI.Lottie(this.step1Mask, balance_guidance, 150, layers.stageHeight / 2 - 166).play(0)
UI.Txt(this.step1Mask, '端平手机开始游戏', 36, '#ffffff', TEXT_ALIGN.CENTER, layers.stageWidth, 0, layers.stageHeight / 2 + 176, true)
UI.Txt(this.step1Mask, '端平手机开始挑战', 36, '#ffffff', TEXT_ALIGN.CENTER, layers.stageWidth, 0, layers.stageHeight / 2 + 176, true)
var p = this.progress = this.step1Mask.addChild(new ProgressBar(0xcccccc, {
width: 450,
......@@ -158,7 +158,7 @@ export class MotionInitFunc extends Container {
onStepDwon() {
var stepDownCtn = UI.Ctn(this)
// UI.Rect(stepDownCtn, 750, 1624, 0x1b1a1a, 0).alpha=0.8
var box1 = UI.Ctn(stepDownCtn)
var desc = UI.Sp(box1, 'ruready.png', layers.stageCenterX, layers.stageCenterY)
desc.anchorTexture.set(0.5, 0.5);
......@@ -178,8 +178,8 @@ export class MotionInitFunc extends Container {
var _y = layers.stageCenterY
return new Promise((resolve, reject) => {
FYGE.Tween.get(desc)
.set({ alpha:0, y: layers.stageCenterY})
.to({ alpha: 1, y: layers.stageCenterY - 150 }, 600 ,FYGE.Ease.quadInOut)
.set({ alpha: 0, y: layers.stageCenterY })
.to({ alpha: 1, y: layers.stageCenterY - 150 }, 600, FYGE.Ease.quadInOut)
.wait(300)
.call(() => {
......@@ -190,8 +190,8 @@ export class MotionInitFunc extends Container {
}, null, null, true)
FYGE.Tween.get(timerBoxTxtSp)
.set({ alpha: 0, y: _y + 150})
.to({ alpha: 1, y: _y }, 300,FYGE.Ease.quadInOut)
.set({ alpha: 0, y: _y + 150 })
.to({ alpha: 1, y: _y }, 300, FYGE.Ease.quadInOut)
.wait(600)
.to({ alpha: 0 }, 100)
.call(() => {
......@@ -200,8 +200,8 @@ export class MotionInitFunc extends Container {
timerBoxTxtSp.texture = RES.getRes('count2.png')
FYGE.Tween.get(timerBoxTxtSp)
.set({ alpha: 0,y: _y + 150})
.to({ alpha: 1, y: _y }, 300,FYGE.Ease.quadInOut)
.set({ alpha: 0, y: _y + 150 })
.to({ alpha: 1, y: _y }, 300, FYGE.Ease.quadInOut)
.wait(600)
.to({ alpha: 0 }, 100)
.call(() => {
......@@ -210,8 +210,8 @@ export class MotionInitFunc extends Container {
timerBoxTxtSp.texture = RES.getRes('count1.png')
FYGE.Tween.get(timerBoxTxtSp)
.set({ alpha: 0,y: _y + 150})
.to({ alpha: 1, y: _y }, 300,FYGE.Ease.quadInOut)
.set({ alpha: 0, y: _y + 150 })
.to({ alpha: 1, y: _y }, 300, FYGE.Ease.quadInOut)
.wait(600)
.call(() => {
//@ts-ignore
......@@ -235,10 +235,10 @@ export class MotionInitFunc extends Container {
})
})
})
})
})
}
guidanceFill = onceFnc(() => {
......@@ -260,10 +260,10 @@ export class MotionInitFunc extends Container {
// }
}
})
.to({value: 1}, 1500)
.to({ value: 1 }, 1500)
.call(async () => {
DeviceMotion.instance.off(this.deviceOritationChange)
// 游戏页面有个倒计时
// 挑战页面有个倒计时
if (this.type != 1) {
this.step1Mask.visible = false
await this.onStepDwon()
......@@ -287,7 +287,7 @@ export class MotionInitFunc extends Container {
export class MotionInitScene extends Scene {
motionInitFunc: MotionInitFunc // 端平action类
holdOnTxt: FYGE.TextField // 保持住文案
gameEle: GameEle // 游戏元素
gameEle: GameEle // 挑战元素
constructor(...args) {
super(...args)
......@@ -308,14 +308,14 @@ export class MotionInitScene extends Scene {
set musicBoolean(m: boolean) {
if (m) {
(this.musicBtn || (this.musicBtn = UI.Btn(this, 'music-on.png', this.onMusicClick, this, 650, layers.stageOffsetY + (getApp().isLarge ? 52 : 5 )))).texture = RES.getRes('music-on.png');
(this.musicBtn || (this.musicBtn = UI.Btn(this, 'music-on.png', this.onMusicClick, this, 650, layers.stageOffsetY + (getApp().isLarge ? 52 : 5)))).texture = RES.getRes('music-on.png');
this.musicBtn.anchorX = 30
this.musicBtn.anchorY = 30
FYGE.Tween.get(this.musicBtn, {loop: true})
.to({rotation: 360}, 5000)
FYGE.Tween.get(this.musicBtn, { loop: true })
.to({ rotation: 360 }, 5000)
} else {
(this.musicBtn || (this.musicBtn = UI.Btn(this, 'music-on.png', this.onMusicClick, this, 650, layers.stageOffsetY + (getApp().isLarge ? 52 : 5 )))).texture = RES.getRes('music-off.png');
(this.musicBtn || (this.musicBtn = UI.Btn(this, 'music-on.png', this.onMusicClick, this, 650, layers.stageOffsetY + (getApp().isLarge ? 52 : 5)))).texture = RES.getRes('music-off.png');
FYGE.Tween.removeTweens(this.musicBtn)
this.musicBtn.rotation = 0
}
......@@ -349,7 +349,7 @@ export class MotionInitScene extends Scene {
UI.Sp(this, 'centerCircle.png', layers.stageCenterX, layers.stageCenterY).anchorTexture.set(.5, .5)
// @ts-ignore
this.focusProgress = this.addChild(new CircleProgressBar({
x: layers.stageCenterX,
......@@ -361,7 +361,7 @@ export class MotionInitScene extends Scene {
this.focusProgress.visible = false
this.centerp = setCenterPos(UI.Sp(this, 'p1-b.png'))
var bitMapc = Tools.getNumTextures('percennt')
bitMapc['%'] = RES.getRes('percenntp.png')
this.bitmapTextCount = this.addChild(new FYGE.BitmapText(bitMapc))
......@@ -403,7 +403,7 @@ export class MotionInitScene extends Scene {
}
protected shoot() {
}
protected unshoot() {
......@@ -425,38 +425,38 @@ export class MotionInitScene extends Scene {
this.bitmapTextCount.visible = true
FYGE.Tween.get(this.holdOnTxt)
.set({visible: true, scaleX: .1, scaleY: .1})
.to({scaleX: 1.08, scaleY: 1.08}, 300)
.to({scaleX: 1, scaleY: 1}, 150)
.set({ visible: true, scaleX: .1, scaleY: .1 })
.to({ scaleX: 1.08, scaleY: 1.08 }, 300)
.to({ scaleX: 1, scaleY: 1 }, 150)
.call(() => {
// vtodo 做wiggle 动效
const _y = this.holdOnTxt.y
const _x = this.holdOnTxt.x
FYGE.Tween.get(this.holdOnTxt, {loop: true})
.to({x: _x -2, y: _y + 2}, 125)
.to({x: _x, y: _y + 1}, 125)
.to({x: _x -2, y: _y + 2}, 125)
.to({x: _x + 1, y: _y -1}, 125)
.to({x: _x + 2, y: _y - 2}, 125)
.to({x: _x, y: _y+1}, 125)
.to({x: _x -2, y: _y - 2}, 125)
.to({x: _x -1, y: _y -1}, 125)
FYGE.Tween.get(this.holdOnTxt, { loop: true })
.to({ x: _x - 2, y: _y + 2 }, 125)
.to({ x: _x, y: _y + 1 }, 125)
.to({ x: _x - 2, y: _y + 2 }, 125)
.to({ x: _x + 1, y: _y - 1 }, 125)
.to({ x: _x + 2, y: _y - 2 }, 125)
.to({ x: _x, y: _y + 1 }, 125)
.to({ x: _x - 2, y: _y - 2 }, 125)
.to({ x: _x - 1, y: _y - 1 }, 125)
})
FYGE.Tween.removeTweens(this.focusProgress)
FYGE.Tween.get(this.focusProgress,{
FYGE.Tween.get(this.focusProgress, {
onChange: () => {
this.bitmapTextCount.text = ((this.focusProgress.value * 100) >> 0) + "%"
}
})
.set({value: 0, visible: true, radius: 240, alpha: 1})
.to({radius: 285}, 300)
.to({value: 1.001}, GameCfg.getHTime(), FYGE.Ease.quartOut)
.set({ value: 0, visible: true, radius: 240, alpha: 1 })
.to({ radius: 285 }, 300)
.to({ value: 1.001 }, GameCfg.getHTime(), FYGE.Ease.quartOut)
.call(() => {
console.log('%c 成功套种', 'color: green');
//@ts-ignore
my && my.vibrateShort()
this.holdOnTxt.visible = false
var icon = (this.excellentIcon || UI.Lottie(this, excellent_icon, 180, 290));
icon.visible = true
......@@ -466,27 +466,27 @@ export class MotionInitScene extends Scene {
typeof e.data == 'function' && e.data()
this.removeTimeCountDown(false)
})
})
}
removeTimeCountDown(istween: boolean = true) {
if (this.focusProgress.visible && istween) {
this.unshoot()
FYGE.Tween.removeTweens(this.focusProgress)
FYGE.Tween.get(this.focusProgress,{
FYGE.Tween.get(this.focusProgress, {
onChange: () => {
this.bitmapTextCount.text = ((this.focusProgress.value * 100) >> 0) + "%"
}
})
.to({value: 0}, 500)
.to({radius: 220, alpha: 0}, 300)
.to({ value: 0 }, 500)
.to({ radius: 220, alpha: 0 }, 300)
.call(() => {
this.focusProgress.visible = false
this.bitmapTextCount.visible = false
})
// FYGE.Tween.removeTweens(this.focusProgress)
} else {
this.focusProgress.visible = false
......
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