Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zeroing-libs
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
劳工
zeroing-libs
Commits
55a77ca7
Commit
55a77ca7
authored
Aug 25, 2020
by
任建锋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加大转盘
parent
33676a89
Changes
15
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
787 additions
and
0 deletions
+787
-0
.DS_Store
.DS_Store
+0
-0
.DS_Store
dist/.DS_Store
+0
-0
turnplate.json
dist/customs/turnplate.json
+75
-0
app.js
src/custom/turnplate/debug/app.js
+191
-0
index.html
src/custom/turnplate/debug/index.html
+52
-0
load-assets.js
src/custom/turnplate/debug/load-assets.js
+64
-0
main.js
src/custom/turnplate/debug/main.js
+130
-0
main.js.map
src/custom/turnplate/debug/main.js.map
+1
-0
props.js
src/custom/turnplate/debug/props.js
+7
-0
meta.json
src/custom/turnplate/meta.json
+73
-0
GameWrapper.ts
src/custom/turnplate/src/game/GameWrapper.ts
+127
-0
object-pool-init.ts
src/custom/turnplate/src/game/object-pool-init.ts
+14
-0
utils.ts
src/custom/turnplate/src/game/utils.ts
+24
-0
index.ts
src/custom/turnplate/src/index.ts
+14
-0
props.ts
src/custom/turnplate/src/props.ts
+15
-0
No files found.
.DS_Store
View file @
55a77ca7
No preview for this file type
dist/.DS_Store
View file @
55a77ca7
No preview for this file type
dist/customs/turnplate.json
0 → 100644
View file @
55a77ca7
{
"name"
:
"大转盘"
,
"desc"
:
"大转盘模块"
,
"props"
:
{
"iconSize"
:
{
"alias"
:
"奖品图的大小"
,
"type"
:
"array<number>"
,
"default"
:
"80,80"
},
"diameter"
:
{
"alias"
:
"圆盘直径"
,
"type"
:
"number"
,
"default"
:
"600"
},
"prizesRadius"
:
{
"alias"
:
"奖品距离圆心的距离"
,
"type"
:
"number"
,
"default"
:
250
},
"nameColor"
:
{
"alias"
:
"奖品名称的字体颜色"
,
"type"
:
"string"
,
"default"
:
"#444444"
},
"nameSize"
:
{
"alias"
:
"奖品名称的字体大小"
,
"type"
:
"number"
,
"default"
:
20
},
"iconY"
:
{
"alias"
:
"奖品名称的Y轴偏移"
,
"type"
:
"number"
,
"default"
:
30
},
"rotationBg"
:
{
"alias"
:
"背景旋转"
,
"type"
:
"number"
,
"default"
:
30
}
},
"assets"
:
[
{
"name"
:
"大转盘背景"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/559177b3c0d4245d245b5cdfa31ba9d9dc20223c.png"
,
"uuid"
:
"d3ce99da-89e1-447d-8c52-b3f391925c3c"
,
"ext"
:
".png"
}
],
"events"
:
{
"in"
:
{
"turnplate-reset"
:
{
"alias"
:
"重置"
,
"data"
:
{
"prizes"
:
"所有奖品"
}
},
"turnplate-start"
:
{
"alias"
:
"开始"
,
"data"
:
{
"prizeId"
:
"中奖的奖品id"
}
}
},
"out"
:
{
"turnplate-over"
:
{
"alias"
:
"转盘停止"
,
"data"
:
{
"prizeId"
:
"中奖的奖品id"
}
}
}
},
"id"
:
"turnplate"
,
"code"
:
"(function (global, factory) {
\n\t
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :
\n\t
typeof define === 'function' && define.amd ? define(['tslib'], factory) :
\n\t
(global = global || self, global.turnplate = factory(global.tslib));
\n
}(this, (function (tslib) { 'use strict';
\n\n\t
var props = {};
\n\t
function prepareProps() {
\n\t
var metaProps = getProps();
\n\t
engine.injectProp(props, metaProps);
\n\t
}
\n\t
function injectProps(p) {
\n\t
engine.injectProp(props, p);
\n\t
}
\n\n\t
function getTextureByName(name) {
\n\t
return engine.Texture.from(getAssetByName(name).uuid);
\n\t
}
\n\n\t
var GameWrapper = (function (_super) {
\n\t
tslib.__extends(GameWrapper, _super);
\n\t
function GameWrapper() {
\n\t
var _this = _super.call(this) || this;
\n\t
_this.wheelPrizeRotation = [];
\n\t
_this.items = [];
\n\t
_this.itemsCon = [];
\n\t
_this.itemsLabel = [];
\n\t
_this.itemsIcon = [];
\n\t
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
\n\t
engine.globalEvent.addEventListener('turnplate-reset', _this.reset, _this);
\n\t
engine.globalEvent.addEventListener('turnplate-start', _this.start, _this);
\n\t
return _this;
\n\t
}
\n\t
GameWrapper.prototype.setup = function () {
\n\t
this.turnplate = new engine.Container();
\n\t
this.turnplate.x = 0;
\n\t
this.turnplate.y = 0;
\n\t
this.turnplate.rotation = -90;
\n\t
this.turnplate.width = props.diameter;
\n\t
this.turnplate.height = props.diameter;
\n\t
this.turnplate.anchorX = this.turnplate.width / 2;
\n\t
this.turnplate.anchorY = this.turnplate.height / 2;
\n\t
this.addChild(this.turnplate);
\n\t
this._turnplateBG = new engine.Container();
\n\t
this._turnplateBG.width = props.diameter;
\n\t
this._turnplateBG.height = props.diameter;
\n\t
this._turnplateBG.anchorX = this.turnplate.width / 2;
\n\t
this._turnplateBG.anchorY = this.turnplate.height / 2;
\n\t
this._turnplateBG.rotation = props.rotationBg;
\n\t
this.turnplate.addChild(this._turnplateBG);
\n\t
this.turnplateBg = new engine.Sprite(getTextureByName('大转盘背景'));
\n\t
this.turnplateBg.x = 0;
\n\t
this.turnplateBg.y = 0;
\n\t
this.turnplateBg.width = this.turnplate.width;
\n\t
this.turnplateBg.height = this.turnplate.height;
\n\t
this._turnplateBG.addChild(this.turnplateBg);
\n\t
};
\n\t
GameWrapper.prototype.reset = function (event) {
\n\t
injectProps(event.data);
\n\t
this.prizes = event.data.prizes;
\n\t
console.log(this.prizes);
\n\t
for (var i = 0; i < this.items.length; i++) {
\n\t
this.itemsCon[i].removeChild(this.itemsLabel[i]);
\n\t
this.itemsCon[i].removeChild(this.itemsIcon[i]);
\n\t
this.items[i].removeChild(this.itemsCon[i]);
\n\t
this.turnplate.removeChild(this.items[i]);
\n\t
}
\n\t
for (var i = 0; i < this.prizes.length; i++) {
\n\t
this.items[i] = new engine.Container();
\n\t
this.itemsCon[i] = new engine.Container();
\n\t
this.itemsCon[i].x = props.prizesRadius;
\n\t
this.itemsCon[i].rotation = 90;
\n\t
this.items[i].x = this.turnplate.width / 2;
\n\t
this.items[i].y = this.turnplate.height / 2;
\n\t
this.turnplate.addChild(this.items[i]);
\n\t
this.itemsLabel[i] = new engine.Label();
\n\t
this.itemsLabel[i].text = this.prizes[i].name;
\n\t
this.itemsLabel[i].width = 200;
\n\t
this.itemsLabel[i].x = -this.itemsLabel[i].width / 2;
\n\t
this.itemsLabel[i].textAlign =
\"
center
\"
;
\n\t
this.itemsLabel[i].fillColor = props.nameColor;
\n\t
this.itemsLabel[i].size = props.nameSize;
\n\t
this.itemsIcon[i] = new engine.Sprite();
\n\t
this.itemsIcon[i].width = props.iconSize[0];
\n\t
this.itemsIcon[i].height = props.iconSize[1];
\n\t
this.itemsIcon[i].x = -this.itemsIcon[i].width / 2;
\n\t
this.itemsIcon[i].y = props.iconY;
\n\t
this.itemsIcon[i].texture = engine.Texture.from(this.prizes[i].icon);
\n\t
this.itemsCon[i].addChild(this.itemsLabel[i]);
\n\t
this.itemsCon[i].addChild(this.itemsIcon[i]);
\n\t
this.items[i].addChild(this.itemsCon[i]);
\n\t
var _rotation = (i) * (360 / this.prizes.length);
\n\t
this.items[i].rotation = _rotation;
\n\t
this.wheelPrizeRotation[this.prizes[i].prizeId] = _rotation;
\n\t
}
\n\t
this.turnplate.rotation = -90;
\n\t
engine.Tween.removeTweens(this.turnplate);
\n\t
engine.Tween.get(this.turnplate, { loop: true })
\n\t
.to({ rotation: 360 - 90 }, 5000);
\n\t
};
\n\t
GameWrapper.prototype.start = function (event) {
\n\t
var _this = this;
\n\t
injectProps(event.data);
\n\t
engine.Tween.removeTweens(this.turnplate);
\n\t
var prizeId = event.data.prizeId;
\n\t
engine.Tween.get(this.turnplate)
\n\t
.to({ rotation: 7200 - this.wheelPrizeRotation[prizeId] - 90 }, 8000, engine.Ease.circInOut)
\n\t
.wait(500)
\n\t
.call(function () {
\n\t
_this.turnplate.rotation = 360 - _this.wheelPrizeRotation[prizeId] + 0.001 - 90;
\n\t
engine.globalEvent.dispatchEvent('turnplate-over', {
\n\t
prizeId: prizeId
\n\t
});
\n\t
});
\n\t
};
\n\t
return GameWrapper;
\n\t
}(engine.Container));
\n\n\t
function index (props) {
\n\t
prepareProps();
\n\t
injectProps(props);
\n\t
var instance = new GameWrapper();
\n\t
return instance;
\n\t
}
\n\n\t
return index;
\n\n
})));
\n
"
}
src/custom/turnplate/debug/app.js
0 → 100644
View file @
55a77ca7
/**
* Created by renjianfeng on 2020-03-13.
*/
const
customId
=
'turnplate'
;
(
async
function
()
{
let
customModule
=
await
fetch
(
`../meta.json`
);
customModule
=
await
customModule
.
json
();
console
.
log
(
customModule
);
await
loadAssets
(
customModule
.
assets
);
launchWithCustomModule
(
customModule
);
})();
function
launchWithCustomModule
(
customModule
)
{
//engine.registerCustomCodeModule(customModule);
engine
.
registerCustomModule
(
customId
,
window
[
customId
]);
const
{
props
:
propsOption
,
assets
}
=
customModule
;
let
props
=
engine
.
computeProps
(
customModuleProps
,
propsOption
);
const
customModuleIns
=
{
id
:
customId
,
props
,
assets
,
};
engine
.
registerCustomModules
([
customModuleIns
]);
engine
.
launchWithConfig
({
options
:
{
entrySceneView
:
'entry'
,
},
assets
:
[],
views
:
[{
name
:
'entry'
,
type
:
'node'
,
properties
:
{
x
:
0
,
y
:
0
,
}
}],
customs
:
[]
},
null
,
function
()
{
setTimeout
(()
=>
{
engine
.
addCustomModule
(
customId
,
engine
.
gameStage
.
sceneContainer
.
getChildAt
(
0
));
},
100
);
setTimeout
(()
=>
{
engine
.
globalEvent
.
dispatchEvent
(
'turnplate-reset'
,
{
prizes
:[
{
"icon"
:
"//yun.dui88.com/images/201907/ui83og75fr.png"
,
"id"
:
"o8c947e58"
,
"index"
:
1
,
"name"
:
"优惠券1"
,
"prizeId"
:
"ga58ef339"
,
"prizeType"
:
2
},
{
"icon"
:
"//yun.duiba.com.cn/db-m/app/turntable/circle/images/prize/谢谢参与_6311f27.png"
,
"id"
:
"thanks"
,
"index"
:
2
,
"name"
:
"谢谢参与"
,
"prizeId"
:
"thanks"
,
"prizeType"
:
0
},
// {
// "icon":"//yun.duiba.com.cn/db-m/app/turntable/circle/images/prize/谢谢参与_6311f27.png",
// "id":"thanks",
// "index":2,
// "name":"谢谢参与",
// "prizeId":"thanks2",
// "prizeType":0
// },
{
"icon"
:
"//yun.dui88.com/images/201907/xsit2cvmyl.jpeg"
,
"id"
:
"ob52caaca"
,
"index"
:
3
,
"name"
:
"实物1"
,
"prizeId"
:
"gb87b2592"
,
"prizeType"
:
2
},
{
"icon"
:
"//yun.dui88.com/projectxh5/alipay-250-250.png"
,
"id"
:
"ob7dc936f"
,
"index"
:
4
,
"name"
:
"支付宝10元"
,
"prizeId"
:
"g1f8062fe"
,
"prizeType"
:
2
},
{
"icon"
:
"//yun.dui88.com/projectxh5/phonebill-250-250.png"
,
"id"
:
"o56bf97cc"
,
"index"
:
5
,
"name"
:
"话费30元"
,
"prizeId"
:
"gbeeb3187"
,
"prizeType"
:
2
},
{
"icon"
:
"//yun.dui88.com/projectxh5/qb-250-250.png"
,
"id"
:
"o6c455e84"
,
"index"
:
6
,
"name"
:
"Q币10个"
,
"prizeId"
:
"g4c4c3edd"
,
"prizeType"
:
2
}
]
});
},
100
)
setTimeout
(()
=>
{
engine
.
globalEvent
.
dispatchEvent
(
'turnplate-start'
,{
"prizeId"
:
"g1f8062fe"
});
},
5000
);
setTimeout
(()
=>
{
engine
.
globalEvent
.
dispatchEvent
(
'turnplate-reset'
,
{
prizes
:[
{
"icon"
:
"//yun.dui88.com/images/201907/ui83og75fr.png"
,
"id"
:
"o8c947e58"
,
"index"
:
1
,
"name"
:
"优惠券1"
,
"prizeId"
:
"ga58ef339"
,
"prizeType"
:
2
},
{
"icon"
:
"//yun.duiba.com.cn/db-m/app/turntable/circle/images/prize/谢谢参与_6311f27.png"
,
"id"
:
"thanks"
,
"index"
:
2
,
"name"
:
"谢谢参与"
,
"prizeId"
:
"thanks"
,
"prizeType"
:
0
},
// {
// "icon":"//yun.duiba.com.cn/db-m/app/turntable/circle/images/prize/谢谢参与_6311f27.png",
// "id":"thanks",
// "index":2,
// "name":"谢谢参与",
// "prizeId":"thanks2",
// "prizeType":0
// },
{
"icon"
:
"//yun.dui88.com/images/201907/xsit2cvmyl.jpeg"
,
"id"
:
"ob52caaca"
,
"index"
:
3
,
"name"
:
"实物1"
,
"prizeId"
:
"gb87b2592"
,
"prizeType"
:
2
},
{
"icon"
:
"//yun.dui88.com/projectxh5/alipay-250-250.png"
,
"id"
:
"ob7dc936f"
,
"index"
:
4
,
"name"
:
"支付宝10元"
,
"prizeId"
:
"g1f8062fe"
,
"prizeType"
:
2
},
{
"icon"
:
"//yun.dui88.com/projectxh5/phonebill-250-250.png"
,
"id"
:
"o56bf97cc"
,
"index"
:
5
,
"name"
:
"话费30元"
,
"prizeId"
:
"gbeeb3187"
,
"prizeType"
:
2
},
{
"icon"
:
"//yun.dui88.com/projectxh5/qb-250-250.png"
,
"id"
:
"o6c455e84"
,
"index"
:
6
,
"name"
:
"Q币1000个"
,
"prizeId"
:
"g4c4c3edd"
,
"prizeType"
:
2
}
]
});
},
20000
);
});
engine
.
globalEvent
.
addEventListener
(
'turnplate-over'
,
(
e
)
=>
{
console
.
log
(
e
.
type
,
e
.
data
);
});
}
function
reset
(){
}
function
getAssetByUUID
(
uuid
)
{
return
engine
.
resolveCustomAsset
(
customId
,
uuid
);
}
function
getProps
()
{
return
engine
.
getProps
(
customId
);
}
src/custom/turnplate/debug/index.html
0 → 100644
View file @
55a77ca7
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
大转盘
</title>
<meta
name=
"viewport"
content=
"width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"
/>
<meta
name=
"apple-mobile-web-app-capable"
content=
"yes"
/>
<meta
name=
"full-screen"
content=
"true"
/>
<meta
name=
"screen-orientation"
content=
"portrait"
/>
<meta
name=
"x5-fullscreen"
content=
"true"
/>
<meta
name=
"360-fullscreen"
content=
"true"
/>
<style>
html
,
body
{
padding
:
0
;
margin
:
0
;
border
:
0
;
width
:
100%
;
height
:
100%
;
overflow
:
hidden
;
position
:
absolute
;
background-color
:
red
;
}
.game-container
{
width
:
100%
;
height
:
100%
;
line-height
:
0
;
font-size
:
0
;
}
</style>
</head>
<body>
<div
id=
"game-container"
class=
"game-container"
></div>
<!-- <script crossorigin="anonymous" src="//yun.duiba.com.cn/editor/zeroing/libs/engine.50cdcef6ebe4e8c0fbc624f9d4fbf225102c5750.js"></script> -->
<script
crossorigin=
"anonymous"
src=
"//yun.duiba.com.cn/editor/zeroing/libs/engine.fbc60c6d3cb30e5ab97e82d392d9efeee91b8581.js"
></script>
<script
crossorigin=
"anonymous"
src=
"//yun.duiba.com.cn/editor/zeroing/libs/svga.fd3923ae6e664251ca7981801a65809cc5f36bc3.js"
></script>
<!-- <script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.ebc906f6b50b8da0a669f77027981d5f3cb560ce.js"></script> -->
<!-- <script src="http://localhost:4002/debug/engine.js"></script>
<script src="http://localhost:4003/debug/engine-svga.js"></script> -->
<!--<script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.9a9dbfda4cb2dd5508ecddfe3d95dfd88063f7b5.js"></script>-->
<script
src=
"app.js"
></script>
<script
src=
"props.js"
></script>
<script
src=
"load-assets.js"
></script>
<script
src=
"main.js"
></script>
<script>
</script>
</body>
\ No newline at end of file
src/custom/turnplate/debug/load-assets.js
0 → 100644
View file @
55a77ca7
/**
* Created by rockyl on 2020-01-21.
*/
const
assets
=
[
{
"name"
:
"雨滴0"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/badb3627bbcc75276a3eed53daa8b0a454ced6eb.png"
,
"uuid"
:
"d3ce99da-89e1-447d-8c52-b3f391925c3c"
,
"ext"
:
".png"
},
{
"name"
:
"雨滴1"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/5cc0092913c571eeb52317b8e1e0dc715793049c.png"
,
"uuid"
:
"02f17008-1d8d-4108-a0fc-03fbc71fd118"
,
"ext"
:
".png"
},
{
"name"
:
"雨滴2"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/4b938949b85d50b36ef0f66450643495efbf7580.png"
,
"uuid"
:
"46aa4f8a-9a6c-4210-8ffd-92da0dd3bc75"
,
"ext"
:
".png"
},
{
"name"
:
"炸弹"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/171e92283cd13c013ee1b76d28d252ff08815d47.png"
,
"uuid"
:
"eb88b42d-e151-4c1b-94b9-7c16f7bfac29"
,
"ext"
:
".png"
},
{
"name"
:
"石块"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/99b0af0c59fe79a415a3f032149cfacc27e3ac2c.png"
,
"uuid"
:
"ab1bdabc-21ba-46bf-9299-6c638f766c88"
,
"ext"
:
".png"
},
{
"name"
:
"水花"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/11b1f49fa3afa3a48f1dd3e3c1eb294e3fa9d886.svga"
,
"uuid"
:
"cdd2268f-ad65-4b5e-a965-ee61b730da21"
,
"ext"
:
".svga"
},
{
"name"
:
"石头svga"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/01aa6fcb33aa8231f075257026eab2f0aeb3c27a.svga"
,
"uuid"
:
"846a139d-0990-4db4-a323-f22379932ee4"
,
"ext"
:
".svga"
},
{
"name"
:
"炸弹svga"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/3b58e7ace031b09c651cf8e7202f9c86e86852c9.svga"
,
"uuid"
:
"d7a3947b-7fcb-48f2-9ddf-2f075d37a619"
,
"ext"
:
".svga"
},
{
"name"
:
"玩家"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/db0130d36ef79865be9c753ea0627027f16341d8.png"
,
"uuid"
:
"4931d296-4421-4a2f-8299-7bab87407c72"
,
"ext"
:
".png"
}
];
function
loadAssets
(
customModuleAssets
,
onProgress
,
onComplete
){
return
engine
.
loadAssets
(
assets
.
concat
(...
customModuleAssets
),
onProgress
,
onComplete
);
}
src/custom/turnplate/debug/main.js
0 → 100644
View file @
55a77ca7
(
function
(
global
,
factory
)
{
typeof
exports
===
'object'
&&
typeof
module
!==
'undefined'
?
module
.
exports
=
factory
(
require
(
'tslib'
))
:
typeof
define
===
'function'
&&
define
.
amd
?
define
([
'tslib'
],
factory
)
:
(
global
=
global
||
self
,
global
.
turnplate
=
factory
(
global
.
tslib
));
}(
this
,
(
function
(
tslib
)
{
'use strict'
;
var
props
=
{};
function
prepareProps
()
{
var
metaProps
=
getProps
();
engine
.
injectProp
(
props
,
metaProps
);
}
function
injectProps
(
p
)
{
engine
.
injectProp
(
props
,
p
);
}
function
getTextureByName
(
name
)
{
return
engine
.
Texture
.
from
(
getAssetByName
(
name
).
uuid
);
}
var
GameWrapper
=
(
function
(
_super
)
{
tslib
.
__extends
(
GameWrapper
,
_super
);
function
GameWrapper
()
{
var
_this
=
_super
.
call
(
this
)
||
this
;
_this
.
wheelPrizeRotation
=
[];
_this
.
items
=
[];
_this
.
itemsCon
=
[];
_this
.
itemsLabel
=
[];
_this
.
itemsIcon
=
[];
_this
.
once
(
engine
.
Event
.
ADDED_TO_STAGE
,
_this
.
setup
,
_this
);
engine
.
globalEvent
.
addEventListener
(
'turnplate-reset'
,
_this
.
reset
,
_this
);
engine
.
globalEvent
.
addEventListener
(
'turnplate-start'
,
_this
.
start
,
_this
);
return
_this
;
}
GameWrapper
.
prototype
.
setup
=
function
()
{
this
.
turnplate
=
new
engine
.
Container
();
this
.
turnplate
.
x
=
0
;
this
.
turnplate
.
y
=
0
;
this
.
turnplate
.
rotation
=
-
90
;
this
.
turnplate
.
width
=
props
.
diameter
;
this
.
turnplate
.
height
=
props
.
diameter
;
this
.
turnplate
.
anchorX
=
this
.
turnplate
.
width
/
2
;
this
.
turnplate
.
anchorY
=
this
.
turnplate
.
height
/
2
;
this
.
addChild
(
this
.
turnplate
);
this
.
_turnplateBG
=
new
engine
.
Container
();
this
.
_turnplateBG
.
width
=
props
.
diameter
;
this
.
_turnplateBG
.
height
=
props
.
diameter
;
this
.
_turnplateBG
.
anchorX
=
this
.
turnplate
.
width
/
2
;
this
.
_turnplateBG
.
anchorY
=
this
.
turnplate
.
height
/
2
;
this
.
_turnplateBG
.
rotation
=
props
.
rotationBg
;
this
.
turnplate
.
addChild
(
this
.
_turnplateBG
);
this
.
turnplateBg
=
new
engine
.
Sprite
(
getTextureByName
(
'大转盘背景'
));
this
.
turnplateBg
.
x
=
0
;
this
.
turnplateBg
.
y
=
0
;
this
.
turnplateBg
.
width
=
this
.
turnplate
.
width
;
this
.
turnplateBg
.
height
=
this
.
turnplate
.
height
;
this
.
_turnplateBG
.
addChild
(
this
.
turnplateBg
);
};
GameWrapper
.
prototype
.
reset
=
function
(
event
)
{
injectProps
(
event
.
data
);
this
.
prizes
=
event
.
data
.
prizes
;
console
.
log
(
this
.
prizes
);
for
(
var
i
=
0
;
i
<
this
.
items
.
length
;
i
++
)
{
this
.
itemsCon
[
i
].
removeChild
(
this
.
itemsLabel
[
i
]);
this
.
itemsCon
[
i
].
removeChild
(
this
.
itemsIcon
[
i
]);
this
.
items
[
i
].
removeChild
(
this
.
itemsCon
[
i
]);
this
.
turnplate
.
removeChild
(
this
.
items
[
i
]);
}
for
(
var
i
=
0
;
i
<
this
.
prizes
.
length
;
i
++
)
{
this
.
items
[
i
]
=
new
engine
.
Container
();
this
.
itemsCon
[
i
]
=
new
engine
.
Container
();
this
.
itemsCon
[
i
].
x
=
props
.
prizesRadius
;
this
.
itemsCon
[
i
].
rotation
=
90
;
this
.
items
[
i
].
x
=
this
.
turnplate
.
width
/
2
;
this
.
items
[
i
].
y
=
this
.
turnplate
.
height
/
2
;
this
.
turnplate
.
addChild
(
this
.
items
[
i
]);
this
.
itemsLabel
[
i
]
=
new
engine
.
Label
();
this
.
itemsLabel
[
i
].
text
=
this
.
prizes
[
i
].
name
;
this
.
itemsLabel
[
i
].
width
=
200
;
this
.
itemsLabel
[
i
].
x
=
-
this
.
itemsLabel
[
i
].
width
/
2
;
this
.
itemsLabel
[
i
].
textAlign
=
"center"
;
this
.
itemsLabel
[
i
].
fillColor
=
props
.
nameColor
;
this
.
itemsLabel
[
i
].
size
=
props
.
nameSize
;
this
.
itemsIcon
[
i
]
=
new
engine
.
Sprite
();
this
.
itemsIcon
[
i
].
width
=
props
.
iconSize
[
0
];
this
.
itemsIcon
[
i
].
height
=
props
.
iconSize
[
1
];
this
.
itemsIcon
[
i
].
x
=
-
this
.
itemsIcon
[
i
].
width
/
2
;
this
.
itemsIcon
[
i
].
y
=
props
.
iconY
;
this
.
itemsIcon
[
i
].
texture
=
engine
.
Texture
.
from
(
this
.
prizes
[
i
].
icon
);
this
.
itemsCon
[
i
].
addChild
(
this
.
itemsLabel
[
i
]);
this
.
itemsCon
[
i
].
addChild
(
this
.
itemsIcon
[
i
]);
this
.
items
[
i
].
addChild
(
this
.
itemsCon
[
i
]);
var
_rotation
=
(
i
)
*
(
360
/
this
.
prizes
.
length
);
this
.
items
[
i
].
rotation
=
_rotation
;
this
.
wheelPrizeRotation
[
this
.
prizes
[
i
].
prizeId
]
=
_rotation
;
}
this
.
turnplate
.
rotation
=
-
90
;
engine
.
Tween
.
removeTweens
(
this
.
turnplate
);
engine
.
Tween
.
get
(
this
.
turnplate
,
{
loop
:
true
})
.
to
({
rotation
:
360
-
90
},
5000
);
};
GameWrapper
.
prototype
.
start
=
function
(
event
)
{
var
_this
=
this
;
injectProps
(
event
.
data
);
engine
.
Tween
.
removeTweens
(
this
.
turnplate
);
var
prizeId
=
event
.
data
.
prizeId
;
engine
.
Tween
.
get
(
this
.
turnplate
)
.
to
({
rotation
:
7200
-
this
.
wheelPrizeRotation
[
prizeId
]
-
90
},
8000
,
engine
.
Ease
.
circInOut
)
.
wait
(
500
)
.
call
(
function
()
{
_this
.
turnplate
.
rotation
=
360
-
_this
.
wheelPrizeRotation
[
prizeId
]
+
0.001
-
90
;
engine
.
globalEvent
.
dispatchEvent
(
'turnplate-over'
,
{
prizeId
:
prizeId
});
});
};
return
GameWrapper
;
}(
engine
.
Container
));
function
index
(
props
)
{
prepareProps
();
injectProps
(
props
);
var
instance
=
new
GameWrapper
();
return
instance
;
}
return
index
;
})));
//# sourceMappingURL=main.js.map
\ No newline at end of file
src/custom/turnplate/debug/main.js.map
0 → 100644
View file @
55a77ca7
This diff is collapsed.
Click to expand it.
src/custom/turnplate/debug/props.js
0 → 100644
View file @
55a77ca7
/**
* Created by rockyl on 2020-01-21.
*/
let
customModuleProps
=
{
};
src/custom/turnplate/meta.json
0 → 100644
View file @
55a77ca7
{
"name"
:
"大转盘"
,
"desc"
:
"大转盘模块"
,
"props"
:
{
"iconSize"
:
{
"alias"
:
"奖品图的大小"
,
"type"
:
"array<number>"
,
"default"
:
"80,80"
},
"diameter"
:
{
"alias"
:
"圆盘直径"
,
"type"
:
"number"
,
"default"
:
"600"
},
"prizesRadius"
:
{
"alias"
:
"奖品距离圆心的距离"
,
"type"
:
"number"
,
"default"
:
250
},
"nameColor"
:
{
"alias"
:
"奖品名称的字体颜色"
,
"type"
:
"string"
,
"default"
:
"#444444"
},
"nameSize"
:
{
"alias"
:
"奖品名称的字体大小"
,
"type"
:
"number"
,
"default"
:
20
},
"iconY"
:
{
"alias"
:
"奖品名称的Y轴偏移"
,
"type"
:
"number"
,
"default"
:
30
},
"rotationBg"
:
{
"alias"
:
"背景旋转"
,
"type"
:
"number"
,
"default"
:
30
}
},
"assets"
:
[
{
"name"
:
"大转盘背景"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/559177b3c0d4245d245b5cdfa31ba9d9dc20223c.png"
,
"uuid"
:
"d3ce99da-89e1-447d-8c52-b3f391925c3c"
,
"ext"
:
".png"
}
],
"events"
:
{
"in"
:
{
"turnplate-reset"
:
{
"alias"
:
"重置"
,
"data"
:{
"prizes"
:
"所有奖品"
}
},
"turnplate-start"
:
{
"alias"
:
"开始"
,
"data"
:{
"prizeId"
:
"中奖的奖品id"
}
}
},
"out"
:
{
"turnplate-over"
:
{
"alias"
:
"转盘停止"
,
"data"
:
{
"prizeId"
:
"中奖的奖品id"
}
}
}
}
}
\ No newline at end of file
src/custom/turnplate/src/game/GameWrapper.ts
0 → 100644
View file @
55a77ca7
/**
* Created by rockyl on 2020-01-09.
*/
import
{
injectProps
,
props
}
from
"../props"
;
import
{
getTextureByName
,
getStage
}
from
"./utils"
;
export
class
GameWrapper
extends
engine
.
Container
{
private
_status
;
constructor
()
{
super
();
this
.
once
(
engine
.
Event
.
ADDED_TO_STAGE
,
this
.
setup
,
this
);
engine
.
globalEvent
.
addEventListener
(
'turnplate-reset'
,
this
.
reset
,
this
);
engine
.
globalEvent
.
addEventListener
(
'turnplate-start'
,
this
.
start
,
this
);
}
turnplate
turnplateBg
_turnplateBG
wheelPrizeRotation
=
[]
items
=
[]
itemsCon
=
[]
itemsLabel
=
[]
itemsIcon
=
[]
setup
(){
this
.
turnplate
=
new
engine
.
Container
();
this
.
turnplate
.
x
=
0
this
.
turnplate
.
y
=
0
this
.
turnplate
.
rotation
=-
90
;
this
.
turnplate
.
width
=
props
.
diameter
;
this
.
turnplate
.
height
=
props
.
diameter
;
this
.
turnplate
.
anchorX
=
this
.
turnplate
.
width
/
2
this
.
turnplate
.
anchorY
=
this
.
turnplate
.
height
/
2
this
.
addChild
(
this
.
turnplate
)
this
.
_turnplateBG
=
new
engine
.
Container
();
this
.
_turnplateBG
.
width
=
props
.
diameter
;
this
.
_turnplateBG
.
height
=
props
.
diameter
;
this
.
_turnplateBG
.
anchorX
=
this
.
turnplate
.
width
/
2
this
.
_turnplateBG
.
anchorY
=
this
.
turnplate
.
height
/
2
this
.
_turnplateBG
.
rotation
=
props
.
rotationBg
;
this
.
turnplate
.
addChild
(
this
.
_turnplateBG
)
this
.
turnplateBg
=
new
engine
.
Sprite
(
getTextureByName
(
'大转盘背景'
));
this
.
turnplateBg
.
x
=
0
;
this
.
turnplateBg
.
y
=
0
;
this
.
turnplateBg
.
width
=
this
.
turnplate
.
width
;
this
.
turnplateBg
.
height
=
this
.
turnplate
.
height
;
this
.
_turnplateBG
.
addChild
(
this
.
turnplateBg
)
}
prizes
reset
(
event
:
engine
.
Event
)
{
injectProps
(
event
.
data
);
this
.
prizes
=
event
.
data
.
prizes
console
.
log
(
this
.
prizes
)
for
(
let
i
=
0
;
i
<
this
.
items
.
length
;
i
++
){
this
.
itemsCon
[
i
].
removeChild
(
this
.
itemsLabel
[
i
])
this
.
itemsCon
[
i
].
removeChild
(
this
.
itemsIcon
[
i
])
this
.
items
[
i
].
removeChild
(
this
.
itemsCon
[
i
])
this
.
turnplate
.
removeChild
(
this
.
items
[
i
])
}
for
(
let
i
=
0
;
i
<
this
.
prizes
.
length
;
i
++
){
this
.
items
[
i
]
=
new
engine
.
Container
();
this
.
itemsCon
[
i
]
=
new
engine
.
Container
();
this
.
itemsCon
[
i
].
x
=
props
.
prizesRadius
this
.
itemsCon
[
i
].
rotation
=
90
;
this
.
items
[
i
].
x
=
this
.
turnplate
.
width
/
2
this
.
items
[
i
].
y
=
this
.
turnplate
.
height
/
2
this
.
turnplate
.
addChild
(
this
.
items
[
i
])
this
.
itemsLabel
[
i
]
=
new
engine
.
Label
();
this
.
itemsLabel
[
i
].
text
=
this
.
prizes
[
i
].
name
;
this
.
itemsLabel
[
i
].
width
=
200
;
this
.
itemsLabel
[
i
].
x
=-
this
.
itemsLabel
[
i
].
width
/
2
this
.
itemsLabel
[
i
].
textAlign
=
"center"
;
this
.
itemsLabel
[
i
].
fillColor
=
props
.
nameColor
;
this
.
itemsLabel
[
i
].
size
=
props
.
nameSize
;
this
.
itemsIcon
[
i
]
=
new
engine
.
Sprite
();
this
.
itemsIcon
[
i
].
width
=
props
.
iconSize
[
0
]
this
.
itemsIcon
[
i
].
height
=
props
.
iconSize
[
1
]
this
.
itemsIcon
[
i
].
x
=-
this
.
itemsIcon
[
i
].
width
/
2
;
this
.
itemsIcon
[
i
].
y
=
props
.
iconY
this
.
itemsIcon
[
i
].
texture
=
engine
.
Texture
.
from
(
this
.
prizes
[
i
].
icon
)
this
.
itemsCon
[
i
].
addChild
(
this
.
itemsLabel
[
i
])
this
.
itemsCon
[
i
].
addChild
(
this
.
itemsIcon
[
i
])
this
.
items
[
i
].
addChild
(
this
.
itemsCon
[
i
])
let
_rotation
=
(
i
)
*
(
360
/
this
.
prizes
.
length
)
this
.
items
[
i
].
rotation
=
_rotation
this
.
wheelPrizeRotation
[
this
.
prizes
[
i
].
prizeId
]
=
_rotation
;
}
this
.
turnplate
.
rotation
=-
90
;
engine
.
Tween
.
removeTweens
(
this
.
turnplate
)
engine
.
Tween
.
get
(
this
.
turnplate
,{
loop
:
true
})
.
to
({
rotation
:
360
-
90
},
5000
,)
}
start
(
event
:
engine
.
Event
)
{
//this.turnplate.rotation=-90;
injectProps
(
event
.
data
);
engine
.
Tween
.
removeTweens
(
this
.
turnplate
)
let
prizeId
=
event
.
data
.
prizeId
engine
.
Tween
.
get
(
this
.
turnplate
)
.
to
({
rotation
:
7200
-
this
.
wheelPrizeRotation
[
prizeId
]
-
90
},
8000
,
engine
.
Ease
.
circInOut
)
.
wait
(
500
)
.
call
(()
=>
{
this
.
turnplate
.
rotation
=
360
-
this
.
wheelPrizeRotation
[
prizeId
]
+
0.001
-
90
engine
.
globalEvent
.
dispatchEvent
(
'turnplate-over'
,
{
prizeId
});
// disRect.visible=false;
// if(prizeId!="thanks"){
// next("success",args)
// }else{
// next("failed",args)
// }
})
}
}
src/custom/turnplate/src/game/object-pool-init.ts
0 → 100644
View file @
55a77ca7
/**
* Created by rockyl on 2020-02-03.
*/
import
{
Goods
}
from
"./Goods"
;
import
ObjectPool
=
engine
.
ObjectPool
;
export
const
PoolName
:
string
=
'goods'
;
ObjectPool
.
registerPool
(
PoolName
,
function
()
{
return
new
Goods
();
},
function
(
item
:
Goods
,
data
)
{
item
.
reset
();
});
src/custom/turnplate/src/game/utils.ts
0 → 100644
View file @
55a77ca7
/**
* Created by rockyl on 2020-01-21.
*/
export
function
getTexture
(
uuid
)
{
return
engine
.
Texture
.
from
(
getAssetByUUID
(
uuid
).
uuid
);
}
export
function
getTextureByName
(
name
)
{
return
engine
.
Texture
.
from
(
getAssetByName
(
name
).
uuid
);
}
export
function
playSound
(
name
)
{
engine
.
playSound
(
getAssetByName
(
name
).
uuid
,
{
keep
:
true
});
}
export
function
createSvga
(
name
,
anchorName
?)
{
let
inst
=
new
svga
.
Svga
();
inst
.
source
=
'asset://'
+
getAssetByName
(
name
).
uuid
;
return
inst
;
}
export
function
getStage
(){
return
engine
.
gameStage
.
stage
;
}
\ No newline at end of file
src/custom/turnplate/src/index.ts
0 → 100644
View file @
55a77ca7
/**
* Created by rockyl on 2019-11-20.
*/
import
{
GameWrapper
}
from
"./game/GameWrapper"
;
import
{
injectProps
,
prepareProps
}
from
"./props"
;
export
default
function
(
props
)
{
prepareProps
();
injectProps
(
props
);
let
instance
=
new
GameWrapper
();
return
instance
;
}
src/custom/turnplate/src/props.ts
0 → 100644
View file @
55a77ca7
/**
* Created by rockyl on 2020-01-21.
*/
export
let
props
:
any
=
{};
export
function
prepareProps
()
{
let
metaProps
=
getProps
();
engine
.
injectProp
(
props
,
metaProps
);
}
export
function
injectProps
(
p
)
{
engine
.
injectProp
(
props
,
p
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment