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
a9c7ec84
Commit
a9c7ec84
authored
Jul 02, 2020
by
lujinlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
-a
parent
e87cb514
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
1147 additions
and
0 deletions
+1147
-0
jiugong-turntable-change.json
dist/customs/jiugong-turntable-change.json
+126
-0
app.js
src/custom/jiugong-turntable-change/debug/app.js
+159
-0
index.html
src/custom/jiugong-turntable-change/debug/index.html
+49
-0
load-assets.js
src/custom/jiugong-turntable-change/debug/load-assets.js
+10
-0
main.js
src/custom/jiugong-turntable-change/debug/main.js
+299
-0
main.js.map
src/custom/jiugong-turntable-change/debug/main.js.map
+1
-0
props.js
src/custom/jiugong-turntable-change/debug/props.js
+7
-0
meta.json
src/custom/jiugong-turntable-change/meta.json
+133
-0
GameView.ts
src/custom/jiugong-turntable-change/src/game/GameView.ts
+45
-0
GameWrapper.ts
src/custom/jiugong-turntable-change/src/game/GameWrapper.ts
+57
-0
Turntable.ts
src/custom/jiugong-turntable-change/src/game/Turntable.ts
+213
-0
utils.ts
src/custom/jiugong-turntable-change/src/game/utils.ts
+19
-0
index.ts
src/custom/jiugong-turntable-change/src/index.ts
+14
-0
props.ts
src/custom/jiugong-turntable-change/src/props.ts
+15
-0
No files found.
dist/customs/jiugong-turntable-change.json
0 → 100644
View file @
a9c7ec84
{
"name"
:
"九宫格抽奖-更换奖池"
,
"desc"
:
"九宫格抽奖模块-更换奖池"
,
"props"
:
{
"horizontal"
:
{
"alias"
:
"横向间距"
,
"type"
:
"number"
,
"default"
:
1
},
"vertical"
:
{
"alias"
:
"纵向间距"
,
"type"
:
"number"
,
"default"
:
1
},
"circleNumber"
:
{
"alias"
:
"至少转的圈数"
,
"type"
:
"number"
,
"default"
:
3
},
"tweenTime"
:
{
"alias"
:
"单个奖品节点动画时间(毫秒)"
,
"type"
:
"number"
,
"default"
:
200
},
"slowTweenTime"
:
{
"alias"
:
"中奖后缓速递增时长"
,
"type"
:
"number"
,
"default"
:
200
},
"icon_width"
:
{
"alias"
:
"奖品图宽度"
,
"type"
:
"number"
,
"default"
:
110
},
"icon_height"
:
{
"alias"
:
"奖品图高度"
,
"type"
:
"number"
,
"default"
:
110
},
"icon_X"
:
{
"alias"
:
"奖品X轴偏移量(底框背景有透明)"
,
"type"
:
"number"
,
"default"
:
0
},
"icon_Y"
:
{
"alias"
:
"奖品Y轴偏移量(底框背景有透明)"
,
"type"
:
"number"
,
"default"
:
-20
},
"prizeName_size"
:
{
"alias"
:
"奖品名字字号"
,
"type"
:
"number"
,
"default"
:
30
},
"prizeName_Ypos"
:
{
"alias"
:
"奖品名字相对于底框的高度"
,
"type"
:
"number"
,
"default"
:
50
},
"prizeName_color"
:
{
"alias"
:
"奖品名字颜色值"
,
"type"
:
"string"
,
"default"
:
"#e8805d"
},
"prizeName_maxLength"
:
{
"alias"
:
"奖品名字最长显示长度"
,
"type"
:
"number"
,
"default"
:
8
},
"prizeName_retainLength"
:
{
"alias"
:
"奖品名字超过长度保留多少字数"
,
"type"
:
"number"
,
"default"
:
5
}
},
"assets"
:
[
{
"name"
:
"unchecked"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/3351a20f982fea1fbcbbb3b85bc03f6b547c8bbc.png"
,
"uuid"
:
"48dc9c00-92c3-4926-8d6b-9eb3e0d0668d"
,
"ext"
:
".png"
},
{
"name"
:
"checked"
,
"url"
:
" //yun.duiba.com.cn/aurora/assets/2a9f9ecc43eb912db553fa4685c1987a937f0198.png"
,
"uuid"
:
"1d7bc84d-689d-4a6a-a023-e4a7b9659083"
,
"ext"
:
".png"
}
],
"events"
:
{
"in"
:
{
"jiugong-turntable-change-init"
:
{
"alias"
:
"初始化"
,
"data"
:
{}
},
"jiugong-turntable-change-prizeData"
:
{
"alias"
:
"奖品数据"
,
"data"
:
{}
},
"jiugong-turntable-change-start"
:
{
"alias"
:
"开始"
,
"data"
:
{}
},
"jiugong-turntable-change-winPrize"
:
{
"alias"
:
"中奖"
,
"data"
:
{}
},
"jiugong-turntable-change-abnormal"
:
{
"alias"
:
"异常"
,
"data"
:
{}
},
"jiugong-turntable-change-reset"
:
{
"alias"
:
"重置"
,
"data"
:
{}
}
},
"out"
:
{
"jiugong-turntable-change-over"
:
{
"alias"
:
"结束"
,
"data"
:
{}
}
}
},
"id"
:
"jiugong-turntable-change"
,
"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['jiugong-turntable-change'] = factory(global.tslib));
\n
}(this, (function (tslib) { 'use strict';
\n\n\t
function getTexture(uuid) {
\r\n\t
return engine.Texture.from(getAssetByUUID(uuid).uuid);
\r\n\t
}
\r\n\t
function getTextureByName(name) {
\r\n\t
return getTexture(engine.getAssetByName(name).uuid);
\r\n\t
}
\r\n\t
//# sourceMappingURL=utils.js.map
\n\n\t
var props = {};
\r\n\t
function prepareProps() {
\r\n\t
var metaProps = getProps();
\r\n\t
engine.injectProp(props, metaProps);
\r\n\t
}
\r\n\t
function injectProps(p) {
\r\n\t
engine.injectProp(props, p);
\r\n\t
}
\r\n\t
//# sourceMappingURL=props.js.map
\n\n\t
var Turntable = (function (_super) {
\r\n\t
tslib.__extends(Turntable, _super);
\r\n\t
function Turntable() {
\r\n\t
var _this = _super.call(this) || this;
\r\n\t
_this._vertical_Y = props.vertical || 20;
\r\n\t
_this._horizontal_X = props.horizontal || 20;
\r\n\t
_this._prizeIndex = 0;
\r\n\t
_this._boxArray = [];
\r\n\t
_this._boxIndex = 0;
\r\n\t
_this.tweenTime = props.tweenTime || 200;
\r\n\t
_this.slowTweenTime = props.slowTweenTime || 200;
\r\n\t
_this.circleNumber = 0;
\r\n\t
_this.turntableOrder = [1, 2, 3, 5, 8, 7, 6, 4];
\r\n\t
_this.recordID = -1;
\r\n\t
_this.boxPrizeIndex = -1;
\r\n\t
_this.slowDown = false;
\r\n\t
_this.isStop = false;
\r\n\t
return _this;
\r\n\t
}
\r\n\t
Turntable.prototype.initData = function (res) {
\r\n\t
this.initTurntable(res);
\r\n\t
this.setNodeOrder();
\r\n\t
};
\r\n\t
Turntable.prototype.initTurntable = function (res) {
\r\n\t
var turnTableNode = null;
\r\n\t
if (this._turnTableNode) {
\r\n\t
this.removeChild(this._turnTableNode);
\r\n\t
this._turnTableNode = null;
\r\n\t
this._boxArray = [];
\r\n\t
this._prizeIndex = 0;
\r\n\t
this._boxIndex = 0;
\r\n\t
}
\r\n\t
turnTableNode = this._turnTableNode = new engine.Container();
\r\n\t
this.addChild(turnTableNode);
\r\n\t
for (var index_Y = 0; index_Y < 3; index_Y++) {
\r\n\t
for (var index_X = 0; index_X < 3; index_X++) {
\r\n\t
if (index_X == 1 && index_Y == 1)
\r\n\t
continue;
\r\n\t
var tmpNode = new engine.Container();
\r\n\t
var unchecked = this.getImage('unchecked', 1);
\r\n\t
var checked = this.getImage('checked', 0);
\r\n\t
tmpNode.width = Math.max(unchecked.width, checked.width);
\r\n\t
this._singleNodeWidth = this._singleNodeWidth ? this._singleNodeWidth : tmpNode.width;
\r\n\t
tmpNode.height = Math.max(unchecked.height, checked.height);
\r\n\t
tmpNode.x = index_X * (tmpNode.width + this._horizontal_X);
\r\n\t
tmpNode.y = index_Y * (tmpNode.height + this._vertical_Y);
\r\n\t
tmpNode.addChild(unchecked);
\r\n\t
tmpNode.addChild(checked);
\r\n\t
var prize = new engine.Sprite(engine.Texture.fromImage(res[this._prizeIndex].img));
\r\n\t
var prizeID = res[this._prizeIndex].id;
\r\n\t
prize.width = props.icon_width;
\r\n\t
prize.height = props.icon_height;
\r\n\t
prize.x = (tmpNode.width - prize.width) / 2 + props.icon_X;
\r\n\t
prize.y = (tmpNode.height - prize.height) / 2 + props.icon_Y;
\r\n\t
tmpNode.prizeID = prizeID;
\r\n\t
tmpNode.addChild(prize);
\r\n\t
var titleLabel = new engine.Label();
\r\n\t
titleLabel.fillColor = props.prizeName_color;
\r\n\t
titleLabel.size = props.prizeName_size;
\r\n\t
titleLabel.width = unchecked.width;
\r\n\t
titleLabel.textAlign = engine.TEXT_ALIGN.CENTER;
\r\n\t
titleLabel.x = 0;
\r\n\t
titleLabel.y = props.prizeName_Ypos;
\r\n\t
titleLabel.text = this.fixTitle(res[this._prizeIndex].name);
\r\n\t
tmpNode.addChild(titleLabel);
\r\n\t
this._prizeIndex++;
\r\n\t
this._boxArray.push(tmpNode);
\r\n\t
turnTableNode.addChild(tmpNode);
\r\n\t
}
\r\n\t
}
\r\n\t
turnTableNode.x = (750 - (this._singleNodeWidth * 3 + this._horizontal_X * 2)) / 2;
\r\n\t
};
\r\n\t
Turntable.prototype.setNodeOrder = function () {
\r\n\t
var tmpNodeArray = [];
\r\n\t
for (var index = 0; index < this.turntableOrder.length; index++) {
\r\n\t
var order = this.turntableOrder[index];
\r\n\t
tmpNodeArray.push(this._boxArray[order - 1]);
\r\n\t
}
\r\n\t
this._boxArray = tmpNodeArray;
\r\n\t
};
\r\n\t
Turntable.prototype.fixTitle = function (name) {
\r\n\t
if (!name) {
\r\n\t
return
\"\"
;
\r\n\t
}
\r\n\t
if (name.split(
\"\"
).length < props.prizeName_maxLength) {
\r\n\t
return name;
\r\n\t
}
\r\n\t
var n =
\"\"
;
\r\n\t
for (var i = 0; i < props.prizeName_retainLength; i++) {
\r\n\t
n += name.split(
\"\"
)[i];
\r\n\t
}
\r\n\t
n +=
\"
...
\"
;
\r\n\t
return n;
\r\n\t
};
\r\n\t
Turntable.prototype.getImage = function (resName, alpha) {
\r\n\t
var tmpImage = new engine.Sprite(getTextureByName(resName));
\r\n\t
tmpImage.x = 0;
\r\n\t
tmpImage.y = 0;
\r\n\t
tmpImage.alpha = alpha;
\r\n\t
tmpImage.name = resName;
\r\n\t
return tmpImage;
\r\n\t
};
\r\n\t
Turntable.prototype.startDraw = function () {
\r\n\t
var _this = this;
\r\n\t
var tmpCheckNode = this._boxArray[this._boxIndex].getChildByName('checked');
\r\n\t
if (this.isStop) {
\r\n\t
engine.Tween.removeTweens(tmpCheckNode);
\r\n\t
return;
\r\n\t
}
\r\n\t
if (this.slowDown) {
\r\n\t
if (this._boxIndex != this.getNodeIndexOFprize()) {
\r\n\t
this.tweenTime += this.slowTweenTime;
\r\n\t
}
\r\n\t
else {
\r\n\t
this.isStop = true;
\r\n\t
this.twinkle(tmpCheckNode);
\r\n\t
}
\r\n\t
}
\r\n\t
engine.Tween.get(tmpCheckNode)
\r\n\t
.to({ alpha: 1 }, this.tweenTime / 2)
\r\n\t
.to({ alpha: 0 }, this.tweenTime / 2)
\r\n\t
.call(function () {
\r\n\t
if (_this.circleNumber >= props.circleNumber && _this.getSlowStart() == _this._boxIndex) {
\r\n\t
_this.slowDown = true;
\r\n\t
}
\r\n\t
_this._boxIndex++;
\r\n\t
if (_this._boxIndex >= _this._boxArray.length) {
\r\n\t
_this._boxIndex = 0;
\r\n\t
_this.circleNumber++;
\r\n\t
}
\r\n\t
_this.startDraw();
\r\n\t
});
\r\n\t
};
\r\n\t
Turntable.prototype.getSlowStart = function () {
\r\n\t
if (this.recordID < 0)
\r\n\t
return -1;
\r\n\t
var tmpIndex = this.getNodeIndexOFprize();
\r\n\t
if (tmpIndex < 4) {
\r\n\t
return tmpIndex + 4;
\r\n\t
}
\r\n\t
else {
\r\n\t
return tmpIndex - 4;
\r\n\t
}
\r\n\t
};
\r\n\t
Turntable.prototype.getNodeIndexOFprize = function () {
\r\n\t
if (this.recordID < 0)
\r\n\t
return -1;
\r\n\t
for (var index = 0; index < this._boxArray.length; index++) {
\r\n\t
var element = this._boxArray[index];
\r\n\t
if (element.prizeID === this.recordID) {
\r\n\t
return index;
\r\n\t
}
\r\n\t
}
\r\n\t
return -1;
\r\n\t
};
\r\n\t
Turntable.prototype.twinkle = function (tmpNode) {
\r\n\t
engine.Tween.removeTweens(tmpNode);
\r\n\t
var twinkleTime = 1;
\r\n\t
engine.Tween.get(tmpNode, { loop: true })
\r\n\t
.to({ alpha: 0 }, 30)
\r\n\t
.to({ alpha: 1 }, 30)
\r\n\t
.call(function () {
\r\n\t
if (twinkleTime > 5) {
\r\n\t
engine.Tween.removeTweens(tmpNode);
\r\n\t
engine.globalEvent.dispatchEvent('jiugong-turntable-change-over');
\r\n\t
return;
\r\n\t
}
\r\n\t
else {
\r\n\t
twinkleTime++;
\r\n\t
}
\r\n\t
});
\r\n\t
};
\r\n\t
Turntable.prototype.setRecordID = function (prizeID) {
\r\n\t
this.recordID = prizeID;
\r\n\t
};
\r\n\t
Turntable.prototype.reset = function () {
\r\n\t
this._boxArray.forEach(function (element) {
\r\n\t
engine.Tween.removeTweens(element.getChildByName('checked'));
\r\n\t
});
\r\n\t
this._boxIndex = 0;
\r\n\t
this.tweenTime = props.tweenTime || 200;
\r\n\t
this.slowTweenTime = props.slowTweenTime || 200;
\r\n\t
this.circleNumber = 0;
\r\n\t
this.recordID = -1;
\r\n\t
this.boxPrizeIndex = -1;
\r\n\t
this.slowDown = false;
\r\n\t
this.isStop = false;
\r\n\t
for (var index = 0; index < this._boxArray.length; index++) {
\r\n\t
var element = this._boxArray[index];
\r\n\t
element.getChildByName('checked').alpha = 0;
\r\n\t
}
\r\n\t
};
\r\n\t
return Turntable;
\r\n\t
}(engine.Container));
\r\n\t
//# sourceMappingURL=turntable.js.map
\n\n\t
var GameView = (function (_super) {
\r\n\t
tslib.__extends(GameView, _super);
\r\n\t
function GameView() {
\r\n\t
return _super.call(this) || this;
\r\n\t
}
\r\n\t
GameView.prototype.setup = function () {
\r\n\t
if (this._hasSetup) {
\r\n\t
return;
\r\n\t
}
\r\n\t
this._hasSetup = true;
\r\n\t
var turntable = this._turntable = new Turntable();
\r\n\t
this.addChild(turntable);
\r\n\t
};
\r\n\t
GameView.prototype.setPrizeData = function (res) {
\r\n\t
this._turntable.initData(res);
\r\n\t
};
\r\n\t
GameView.prototype.startDraw = function () {
\r\n\t
this._turntable.startDraw();
\r\n\t
};
\r\n\t
GameView.prototype.setRecordID = function (prizeID) {
\r\n\t
this._turntable.setRecordID(prizeID);
\r\n\t
};
\r\n\t
GameView.prototype.reset = function () {
\r\n\t
this._turntable.reset();
\r\n\t
};
\r\n\t
GameView.prototype.setSetup = function () {
\r\n\t
this._hasSetup = false;
\r\n\t
};
\r\n\t
return GameView;
\r\n\t
}(engine.Container));
\r\n\t
//# sourceMappingURL=GameView.js.map
\n\n\t
var GameWrapper = (function (_super) {
\r\n\t
tslib.__extends(GameWrapper, _super);
\r\n\t
function GameWrapper() {
\r\n\t
var _this = _super.call(this) || this;
\r\n\t
engine.globalEvent.addEventListener('jiugong-turntable-change-init', _this.init, _this);
\r\n\t
engine.globalEvent.addEventListener('jiugong-turntable-change-prizeData', _this.initPrizeData, _this);
\r\n\t
engine.globalEvent.addEventListener('jiugong-turntable-change-start', _this.start, _this);
\r\n\t
engine.globalEvent.addEventListener('jiugong-turntable-change-winPrize', _this.winPrize, _this);
\r\n\t
engine.globalEvent.addEventListener('jiugong-turntable-change-reset', _this.reset, _this);
\r\n\t
engine.globalEvent.addEventListener('jiugong-turntable-change-abnormal', _this.reset, _this);
\r\n\t
return _this;
\r\n\t
}
\r\n\t
GameWrapper.prototype.init = function (event) {
\r\n\t
var gameView = this._gameView = new GameView();
\r\n\t
this.addChild(gameView);
\r\n\t
this._gameView.setup();
\r\n\t
};
\r\n\t
GameWrapper.prototype.initPrizeData = function (event) {
\r\n\t
this._gameView.setSetup();
\r\n\t
this._gameView.setPrizeData(event.data.resources);
\r\n\t
};
\r\n\t
GameWrapper.prototype.start = function (event) {
\r\n\t
this._gameView.startDraw();
\r\n\t
};
\r\n\t
GameWrapper.prototype.winPrize = function (event) {
\r\n\t
this._gameView.setRecordID(event.data.prizeID);
\r\n\t
};
\r\n\t
GameWrapper.prototype.reset = function () {
\r\n\t
this._gameView.reset();
\r\n\t
};
\r\n\t
return GameWrapper;
\r\n\t
}(engine.Container));
\r\n\t
//# sourceMappingURL=GameWrapper.js.map
\n\n\t
function index (props) {
\r\n\t
prepareProps();
\r\n\t
injectProps(props);
\r\n\t
var instance = new GameWrapper();
\r\n\t
return instance;
\r\n\t
}
\r\n\t
//# sourceMappingURL=index.js.map
\n\n\t
return index;
\n\n
})));
\n
"
}
src/custom/jiugong-turntable-change/debug/app.js
0 → 100644
View file @
a9c7ec84
/**
* Created by rockyl on 2019-12-16.
*/
const
customId
=
'jiugong-turntable-change'
;
(
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
,
}
}],
},
null
,
function
()
{
setTimeout
(()
=>
{
engine
.
addCustomModule
(
customId
,
engine
.
gameStage
.
sceneContainer
.
getChildAt
(
0
));
},
100
);
let
pram
=
[
{
id
:
1
,
name
:
'奖品1奖品1'
,
img
:
'//yun.dui88.com/images/201907/ui83og75fr.png'
},
{
id
:
2
,
name
:
'奖品2奖品2奖品2'
,
img
:
'//yun.dui88.com/images/201907/ui83og75fr.png'
},
{
id
:
3
,
name
:
'奖品333333'
,
img
:
'//yun.dui88.com/images/201907/ui83og75fr.png'
},
{
id
:
4
,
name
:
'奖品4545545454'
,
img
:
'//yun.dui88.com/images/201907/ui83og75fr.png'
},
{
id
:
5
,
name
:
'奖奖品5奖品5奖品5品5'
,
img
:
'//yun.dui88.com/images/201907/ui83og75fr.png'
},
{
id
:
6
,
name
:
'奖品6'
,
img
:
'//yun.dui88.com/images/201907/ui83og75fr.png'
},
{
id
:
7
,
name
:
'奖品7'
,
img
:
'//yun.dui88.com/images/201907/ui83og75fr.png'
},
{
id
:
8
,
name
:
'奖品奖品5奖品5奖品58'
,
img
:
'//yun.dui88.com/images/201907/ui83og75fr.png'
}
]
setTimeout
(()
=>
{
engine
.
globalEvent
.
dispatchEvent
(
'jiugong-turntable-change-init'
)
},
1000
);
setTimeout
(()
=>
{
engine
.
globalEvent
.
dispatchEvent
(
'jiugong-turntable-change-prizeData'
,{
resources
:
pram
})
},
1500
);
setTimeout
(()
=>
{
engine
.
globalEvent
.
dispatchEvent
(
'jiugong-turntable-change-start'
)
},
4000
);
let
pram1
=
[
{
id
:
1
,
name
:
'奖品1'
,
img
:
'//yun.dui88.com/images/201907/ui83og75fr.png'
},
{
id
:
2
,
name
:
'奖品2'
,
img
:
'//yun.dui88.com/images/201907/ui83og75fr.png'
},
{
id
:
3
,
name
:
'奖品3'
,
img
:
'//yun.dui88.com/images/201907/ui83og75fr.png'
},
{
id
:
4
,
name
:
'奖品4'
,
img
:
'//yun.dui88.com/images/201907/ui83og75fr.png'
},
{
id
:
5
,
name
:
'奖品5'
,
img
:
'//yun.dui88.com/images/201907/ui83og75fr.png'
},
{
id
:
6
,
name
:
'奖品6'
,
img
:
'//yun.dui88.com/images/201907/ui83og75fr.png'
},
{
id
:
7
,
name
:
'奖品7'
,
img
:
'//yun.dui88.com/images/201907/ui83og75fr.png'
},
{
id
:
8
,
name
:
'奖品8'
,
img
:
'//yun.dui88.com/images/201907/ui83og75fr.png'
}
]
setTimeout
(()
=>
{
engine
.
globalEvent
.
dispatchEvent
(
'jiugong-turntable-change-winPrize'
,{
prizeID
:
4
})
},
6000
);
// setTimeout(() => {
// engine.globalEvent.dispatchEvent('jiugong-turntable-change-prizeData',{resources:pram1})
// }, 10000);
});
}
function
getAssetByUUID
(
uuid
)
{
return
engine
.
resolveCustomAsset
(
customId
,
uuid
);
}
function
getProps
()
{
return
engine
.
getProps
(
customId
);
}
src/custom/jiugong-turntable-change/debug/index.html
0 → 100644
View file @
a9c7ec84
<!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
:
#000000
;
}
</style>
</head>
<body>
<div
id=
"game-container"
style=
"line-height:0;font-size:0"
></div>
<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>-->
<!--//yun.duiba.com.cn/aurora/assets/6a63b68a1fd87eaf60a515968f91a0b1014fe640.ttf-->
<script
src=
"//yun.duiba.com.cn/editor/zeroing/libs/svga.fd3923ae6e664251ca7981801a65809cc5f36bc3.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/jiugong-turntable-change/debug/load-assets.js
0 → 100644
View file @
a9c7ec84
/**
* Created by rockyl on 2020-01-21.
*/
const
assets
=
[
];
function
loadAssets
(
customModuleAssets
,
onProgress
,
onComplete
){
return
engine
.
loadAssets
(
assets
.
concat
(...
customModuleAssets
),
onProgress
,
onComplete
);
}
src/custom/jiugong-turntable-change/debug/main.js
0 → 100644
View file @
a9c7ec84
(
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
[
'jiugong-turntable-change'
]
=
factory
(
global
.
tslib
));
}(
this
,
(
function
(
tslib
)
{
'use strict'
;
function
getTexture
(
uuid
)
{
return
engine
.
Texture
.
from
(
getAssetByUUID
(
uuid
).
uuid
);
}
function
getTextureByName
(
name
)
{
return
getTexture
(
engine
.
getAssetByName
(
name
).
uuid
);
}
//# sourceMappingURL=utils.js.map
var
props
=
{};
function
prepareProps
()
{
var
metaProps
=
getProps
();
engine
.
injectProp
(
props
,
metaProps
);
}
function
injectProps
(
p
)
{
engine
.
injectProp
(
props
,
p
);
}
//# sourceMappingURL=props.js.map
var
Turntable
=
(
function
(
_super
)
{
tslib
.
__extends
(
Turntable
,
_super
);
function
Turntable
()
{
var
_this
=
_super
.
call
(
this
)
||
this
;
_this
.
_vertical_Y
=
props
.
vertical
||
20
;
_this
.
_horizontal_X
=
props
.
horizontal
||
20
;
_this
.
_prizeIndex
=
0
;
_this
.
_boxArray
=
[];
_this
.
_boxIndex
=
0
;
_this
.
tweenTime
=
props
.
tweenTime
||
200
;
_this
.
slowTweenTime
=
props
.
slowTweenTime
||
200
;
_this
.
circleNumber
=
0
;
_this
.
turntableOrder
=
[
1
,
2
,
3
,
5
,
8
,
7
,
6
,
4
];
_this
.
recordID
=
-
1
;
_this
.
boxPrizeIndex
=
-
1
;
_this
.
slowDown
=
false
;
_this
.
isStop
=
false
;
return
_this
;
}
Turntable
.
prototype
.
initData
=
function
(
res
)
{
this
.
initTurntable
(
res
);
this
.
setNodeOrder
();
};
Turntable
.
prototype
.
initTurntable
=
function
(
res
)
{
var
turnTableNode
=
null
;
if
(
this
.
_turnTableNode
)
{
this
.
removeChild
(
this
.
_turnTableNode
);
this
.
_turnTableNode
=
null
;
this
.
_boxArray
=
[];
this
.
_prizeIndex
=
0
;
this
.
_boxIndex
=
0
;
}
turnTableNode
=
this
.
_turnTableNode
=
new
engine
.
Container
();
this
.
addChild
(
turnTableNode
);
for
(
var
index_Y
=
0
;
index_Y
<
3
;
index_Y
++
)
{
for
(
var
index_X
=
0
;
index_X
<
3
;
index_X
++
)
{
if
(
index_X
==
1
&&
index_Y
==
1
)
continue
;
var
tmpNode
=
new
engine
.
Container
();
var
unchecked
=
this
.
getImage
(
'unchecked'
,
1
);
var
checked
=
this
.
getImage
(
'checked'
,
0
);
tmpNode
.
width
=
Math
.
max
(
unchecked
.
width
,
checked
.
width
);
this
.
_singleNodeWidth
=
this
.
_singleNodeWidth
?
this
.
_singleNodeWidth
:
tmpNode
.
width
;
tmpNode
.
height
=
Math
.
max
(
unchecked
.
height
,
checked
.
height
);
tmpNode
.
x
=
index_X
*
(
tmpNode
.
width
+
this
.
_horizontal_X
);
tmpNode
.
y
=
index_Y
*
(
tmpNode
.
height
+
this
.
_vertical_Y
);
tmpNode
.
addChild
(
unchecked
);
tmpNode
.
addChild
(
checked
);
var
prize
=
new
engine
.
Sprite
(
engine
.
Texture
.
fromImage
(
res
[
this
.
_prizeIndex
].
img
));
var
prizeID
=
res
[
this
.
_prizeIndex
].
id
;
prize
.
width
=
props
.
icon_width
;
prize
.
height
=
props
.
icon_height
;
prize
.
x
=
(
tmpNode
.
width
-
prize
.
width
)
/
2
+
props
.
icon_X
;
prize
.
y
=
(
tmpNode
.
height
-
prize
.
height
)
/
2
+
props
.
icon_Y
;
tmpNode
.
prizeID
=
prizeID
;
tmpNode
.
addChild
(
prize
);
var
titleLabel
=
new
engine
.
Label
();
titleLabel
.
fillColor
=
props
.
prizeName_color
;
titleLabel
.
size
=
props
.
prizeName_size
;
titleLabel
.
width
=
unchecked
.
width
;
titleLabel
.
textAlign
=
engine
.
TEXT_ALIGN
.
CENTER
;
titleLabel
.
x
=
0
;
titleLabel
.
y
=
props
.
prizeName_Ypos
;
titleLabel
.
text
=
this
.
fixTitle
(
res
[
this
.
_prizeIndex
].
name
);
tmpNode
.
addChild
(
titleLabel
);
this
.
_prizeIndex
++
;
this
.
_boxArray
.
push
(
tmpNode
);
turnTableNode
.
addChild
(
tmpNode
);
}
}
turnTableNode
.
x
=
(
750
-
(
this
.
_singleNodeWidth
*
3
+
this
.
_horizontal_X
*
2
))
/
2
;
};
Turntable
.
prototype
.
setNodeOrder
=
function
()
{
var
tmpNodeArray
=
[];
for
(
var
index
=
0
;
index
<
this
.
turntableOrder
.
length
;
index
++
)
{
var
order
=
this
.
turntableOrder
[
index
];
tmpNodeArray
.
push
(
this
.
_boxArray
[
order
-
1
]);
}
this
.
_boxArray
=
tmpNodeArray
;
};
Turntable
.
prototype
.
fixTitle
=
function
(
name
)
{
if
(
!
name
)
{
return
""
;
}
if
(
name
.
split
(
""
).
length
<
props
.
prizeName_maxLength
)
{
return
name
;
}
var
n
=
""
;
for
(
var
i
=
0
;
i
<
props
.
prizeName_retainLength
;
i
++
)
{
n
+=
name
.
split
(
""
)[
i
];
}
n
+=
"..."
;
return
n
;
};
Turntable
.
prototype
.
getImage
=
function
(
resName
,
alpha
)
{
var
tmpImage
=
new
engine
.
Sprite
(
getTextureByName
(
resName
));
tmpImage
.
x
=
0
;
tmpImage
.
y
=
0
;
tmpImage
.
alpha
=
alpha
;
tmpImage
.
name
=
resName
;
return
tmpImage
;
};
Turntable
.
prototype
.
startDraw
=
function
()
{
var
_this
=
this
;
var
tmpCheckNode
=
this
.
_boxArray
[
this
.
_boxIndex
].
getChildByName
(
'checked'
);
if
(
this
.
isStop
)
{
engine
.
Tween
.
removeTweens
(
tmpCheckNode
);
return
;
}
if
(
this
.
slowDown
)
{
if
(
this
.
_boxIndex
!=
this
.
getNodeIndexOFprize
())
{
this
.
tweenTime
+=
this
.
slowTweenTime
;
}
else
{
this
.
isStop
=
true
;
this
.
twinkle
(
tmpCheckNode
);
}
}
engine
.
Tween
.
get
(
tmpCheckNode
)
.
to
({
alpha
:
1
},
this
.
tweenTime
/
2
)
.
to
({
alpha
:
0
},
this
.
tweenTime
/
2
)
.
call
(
function
()
{
if
(
_this
.
circleNumber
>=
props
.
circleNumber
&&
_this
.
getSlowStart
()
==
_this
.
_boxIndex
)
{
_this
.
slowDown
=
true
;
}
_this
.
_boxIndex
++
;
if
(
_this
.
_boxIndex
>=
_this
.
_boxArray
.
length
)
{
_this
.
_boxIndex
=
0
;
_this
.
circleNumber
++
;
}
_this
.
startDraw
();
});
};
Turntable
.
prototype
.
getSlowStart
=
function
()
{
if
(
this
.
recordID
<
0
)
return
-
1
;
var
tmpIndex
=
this
.
getNodeIndexOFprize
();
if
(
tmpIndex
<
4
)
{
return
tmpIndex
+
4
;
}
else
{
return
tmpIndex
-
4
;
}
};
Turntable
.
prototype
.
getNodeIndexOFprize
=
function
()
{
if
(
this
.
recordID
<
0
)
return
-
1
;
for
(
var
index
=
0
;
index
<
this
.
_boxArray
.
length
;
index
++
)
{
var
element
=
this
.
_boxArray
[
index
];
if
(
element
.
prizeID
===
this
.
recordID
)
{
return
index
;
}
}
return
-
1
;
};
Turntable
.
prototype
.
twinkle
=
function
(
tmpNode
)
{
engine
.
Tween
.
removeTweens
(
tmpNode
);
var
twinkleTime
=
1
;
engine
.
Tween
.
get
(
tmpNode
,
{
loop
:
true
})
.
to
({
alpha
:
0
},
30
)
.
to
({
alpha
:
1
},
30
)
.
call
(
function
()
{
if
(
twinkleTime
>
5
)
{
engine
.
Tween
.
removeTweens
(
tmpNode
);
engine
.
globalEvent
.
dispatchEvent
(
'jiugong-turntable-change-over'
);
return
;
}
else
{
twinkleTime
++
;
}
});
};
Turntable
.
prototype
.
setRecordID
=
function
(
prizeID
)
{
this
.
recordID
=
prizeID
;
};
Turntable
.
prototype
.
reset
=
function
()
{
this
.
_boxArray
.
forEach
(
function
(
element
)
{
engine
.
Tween
.
removeTweens
(
element
.
getChildByName
(
'checked'
));
});
this
.
_boxIndex
=
0
;
this
.
tweenTime
=
props
.
tweenTime
||
200
;
this
.
slowTweenTime
=
props
.
slowTweenTime
||
200
;
this
.
circleNumber
=
0
;
this
.
recordID
=
-
1
;
this
.
boxPrizeIndex
=
-
1
;
this
.
slowDown
=
false
;
this
.
isStop
=
false
;
for
(
var
index
=
0
;
index
<
this
.
_boxArray
.
length
;
index
++
)
{
var
element
=
this
.
_boxArray
[
index
];
element
.
getChildByName
(
'checked'
).
alpha
=
0
;
}
};
return
Turntable
;
}(
engine
.
Container
));
//# sourceMappingURL=turntable.js.map
var
GameView
=
(
function
(
_super
)
{
tslib
.
__extends
(
GameView
,
_super
);
function
GameView
()
{
return
_super
.
call
(
this
)
||
this
;
}
GameView
.
prototype
.
setup
=
function
()
{
if
(
this
.
_hasSetup
)
{
return
;
}
this
.
_hasSetup
=
true
;
var
turntable
=
this
.
_turntable
=
new
Turntable
();
this
.
addChild
(
turntable
);
};
GameView
.
prototype
.
setPrizeData
=
function
(
res
)
{
this
.
_turntable
.
initData
(
res
);
};
GameView
.
prototype
.
startDraw
=
function
()
{
this
.
_turntable
.
startDraw
();
};
GameView
.
prototype
.
setRecordID
=
function
(
prizeID
)
{
this
.
_turntable
.
setRecordID
(
prizeID
);
};
GameView
.
prototype
.
reset
=
function
()
{
this
.
_turntable
.
reset
();
};
GameView
.
prototype
.
setSetup
=
function
()
{
this
.
_hasSetup
=
false
;
};
return
GameView
;
}(
engine
.
Container
));
//# sourceMappingURL=GameView.js.map
var
GameWrapper
=
(
function
(
_super
)
{
tslib
.
__extends
(
GameWrapper
,
_super
);
function
GameWrapper
()
{
var
_this
=
_super
.
call
(
this
)
||
this
;
engine
.
globalEvent
.
addEventListener
(
'jiugong-turntable-change-init'
,
_this
.
init
,
_this
);
engine
.
globalEvent
.
addEventListener
(
'jiugong-turntable-change-prizeData'
,
_this
.
initPrizeData
,
_this
);
engine
.
globalEvent
.
addEventListener
(
'jiugong-turntable-change-start'
,
_this
.
start
,
_this
);
engine
.
globalEvent
.
addEventListener
(
'jiugong-turntable-change-winPrize'
,
_this
.
winPrize
,
_this
);
engine
.
globalEvent
.
addEventListener
(
'jiugong-turntable-change-reset'
,
_this
.
reset
,
_this
);
engine
.
globalEvent
.
addEventListener
(
'jiugong-turntable-change-abnormal'
,
_this
.
reset
,
_this
);
return
_this
;
}
GameWrapper
.
prototype
.
init
=
function
(
event
)
{
var
gameView
=
this
.
_gameView
=
new
GameView
();
this
.
addChild
(
gameView
);
this
.
_gameView
.
setup
();
};
GameWrapper
.
prototype
.
initPrizeData
=
function
(
event
)
{
this
.
_gameView
.
setSetup
();
this
.
_gameView
.
setPrizeData
(
event
.
data
.
resources
);
};
GameWrapper
.
prototype
.
start
=
function
(
event
)
{
this
.
_gameView
.
startDraw
();
};
GameWrapper
.
prototype
.
winPrize
=
function
(
event
)
{
this
.
_gameView
.
setRecordID
(
event
.
data
.
prizeID
);
};
GameWrapper
.
prototype
.
reset
=
function
()
{
this
.
_gameView
.
reset
();
};
return
GameWrapper
;
}(
engine
.
Container
));
//# sourceMappingURL=GameWrapper.js.map
function
index
(
props
)
{
prepareProps
();
injectProps
(
props
);
var
instance
=
new
GameWrapper
();
return
instance
;
}
//# sourceMappingURL=index.js.map
return
index
;
})));
//# sourceMappingURL=main.js.map
\ No newline at end of file
src/custom/jiugong-turntable-change/debug/main.js.map
0 → 100644
View file @
a9c7ec84
{"version":3,"file":"index.js","sources":["src/custom/jiugong-turntable-change/src/game/utils.ts","src/custom/jiugong-turntable-change/src/props.ts","src/custom/jiugong-turntable-change/src/game/turntable.ts","src/custom/jiugong-turntable-change/src/game/GameView.ts","src/custom/jiugong-turntable-change/src/game/GameWrapper.ts","src/custom/jiugong-turntable-change/src/index.ts"],"sourcesContent":["\r\n/**\r\n * Created by rockyl on 2020-01-21.\r\n */\r\n\r\nexport function getTexture(uuid) {\r\n\treturn engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n}\r\n\r\nexport function getTextureByName(name) {\r\n\treturn getTexture(engine.getAssetByName(name).uuid);\r\n}\r\n\r\nexport function playSound(name) {\r\n\tengine.playSound(engine.getAssetByName(name).uuid, {keep: true});\r\n}\r\nexport function getStage(){\r\n\treturn engine.gameStage.stage;\r\n}","/**\r\n * Created by rockyl on 2020-01-21.\r\n */\r\n\r\nexport let props: any = {};\r\n\r\nexport function prepareProps() {\r\n\tlet metaProps = getProps();\r\n\r\n\tengine.injectProp(props, metaProps);\r\n}\r\n\r\nexport function injectProps(p) {\r\n\tengine.injectProp(props, p);\r\n}\r\n","\r\nimport {getTextureByName} from \"./utils\";\r\nimport {getStage} from \"./utils\";\r\n\r\nimport { props } from '../props';\r\n\r\nexport class Turntable extends engine.Container{\r\n private _turnTableNode:engine.Container;\r\n private _vertical_Y = props.vertical || 20;//纵向间距\r\n private _horizontal_X = props.horizontal || 20;//横向间距\r\n private _prizeIndex = 0;\r\n\r\n private _boxArray = [];\r\n private _boxIndex = 0;//当前下标\r\n\r\n private tweenTime = props.tweenTime || 200;//单个动画时间(毫秒)\r\n private slowTweenTime = props.slowTweenTime || 200;\r\n private circleNumber = 0;//圈数\r\n\r\n private turntableOrder = [1,2,3,5,8,7,6,4]; \r\n private recordID = -1;//中奖奖品ID\r\n private boxPrizeIndex = -1;//中奖奖品节点下标 \r\n private slowDown = false;//是否开始缓速\r\n private isStop = false;\r\n\r\n private _singleNodeWidth;//单个节点宽度\r\n constructor(){\r\n super()\r\n \r\n }\r\n public initData(res){\r\n this.initTurntable(res);\r\n this.setNodeOrder();\r\n }\r\n initTurntable(res){\r\n let turnTableNode = null;\r\n if(this._turnTableNode){\r\n this.removeChild(this._turnTableNode);\r\n this._turnTableNode = null;\r\n this._boxArray = [];\r\n this._prizeIndex = 0;\r\n this._boxIndex = 0;\r\n }\r\n turnTableNode = this._turnTableNode = new engine.Container();\r\n //turnTableNode.y = 50;\r\n this.addChild(turnTableNode);\r\n for (let index_Y = 0; index_Y < 3; index_Y++) {\r\n for (let index_X = 0; index_X < 3; index_X++) { \r\n if(index_X == 1 && index_Y == 1)continue;\r\n let tmpNode:any = new engine.Container()\r\n\r\n let unchecked = this.getImage('unchecked',1);\r\n let checked = this.getImage('checked',0);\r\n\r\n tmpNode.width = Math.max(unchecked.width,checked.width);\r\n this._singleNodeWidth = this._singleNodeWidth ? this._singleNodeWidth : tmpNode.width;\r\n tmpNode.height = Math.max(unchecked.height,checked.height);\r\n tmpNode.x = index_X*(tmpNode.width + this._horizontal_X);\r\n tmpNode.y = index_Y*(tmpNode.height + this._vertical_Y);\r\n tmpNode.addChild(unchecked);\r\n tmpNode.addChild(checked);\r\n \r\n let prize =new engine.Sprite(engine.Texture.fromImage(res[this._prizeIndex].img)) ;\r\n let prizeID = res[this._prizeIndex].id;\r\n prize.width = props.icon_width;\r\n prize.height = props.icon_height;\r\n prize.x = (tmpNode.width - prize.width)/2 + props.icon_X;\r\n prize.y = (tmpNode.height - prize.height)/2 + props.icon_Y;\r\n tmpNode.prizeID = prizeID;\r\n tmpNode.addChild(prize);\r\n \r\n let titleLabel = new engine.Label();\r\n titleLabel.fillColor = props.prizeName_color;\r\n titleLabel.size = props.prizeName_size;\r\n titleLabel.width = unchecked.width;\r\n titleLabel.textAlign = engine.TEXT_ALIGN.CENTER;\r\n titleLabel.x = 0;\r\n titleLabel.y = props.prizeName_Ypos;\r\n \r\n titleLabel.text = this.fixTitle(res[this._prizeIndex].name);\r\n tmpNode.addChild(titleLabel)\r\n \r\n this._prizeIndex ++ ;\r\n this._boxArray.push(tmpNode); \r\n turnTableNode.addChild(tmpNode); \r\n }\r\n }\r\n turnTableNode.x = (750 - (this._singleNodeWidth*3 + this._horizontal_X*2))/2;\r\n }\r\n\r\n setNodeOrder(){\r\n let tmpNodeArray = [];\r\n for (let index = 0; index < this.turntableOrder.length; index++) {\r\n let order = this.turntableOrder[index];\r\n tmpNodeArray.push(this._boxArray[order-1]);\r\n }\r\n this._boxArray = tmpNodeArray;\r\n }\r\n\r\n fixTitle(name){\r\n if(!name){\r\n return \"\"\r\n }\r\n if(name.split(\"\").length<props.prizeName_maxLength){\r\n return name\r\n }\r\n let n = \"\"\r\n for(let i=0;i<props.prizeName_retainLength;i++){\r\n n += name.split(\"\")[i]\r\n }\r\n n+=\"...\"\r\n return n\r\n }\r\n\r\n getImage(resName,alpha){\r\n let tmpImage = new engine.Sprite(getTextureByName(resName));\r\n tmpImage.x = 0\r\n tmpImage.y = 0\r\n tmpImage.alpha = alpha;\r\n tmpImage.name = resName;\r\n return tmpImage;\r\n }\r\n startDraw(){\r\n let tmpCheckNode = this._boxArray[this._boxIndex].getChildByName('checked');\r\n if(this.isStop){engine.Tween.removeTweens(tmpCheckNode);return}\r\n if(this.slowDown)\r\n {\r\n if(this._boxIndex != this.getNodeIndexOFprize()){\r\n this.tweenTime += this.slowTweenTime;\r\n }else{\r\n this.isStop = true;\r\n this.twinkle(tmpCheckNode);\r\n }\r\n }\r\n engine.Tween.get(tmpCheckNode)\r\n .to({alpha:1},this.tweenTime/2)\r\n .to({alpha:0},this.tweenTime/2)\r\n .call(()=>{\r\n if(this.circleNumber >= props.circleNumber && this.getSlowStart() == this._boxIndex){\r\n this.slowDown = true;\r\n }\r\n this._boxIndex ++;\r\n if(this._boxIndex >= this._boxArray.length){\r\n this._boxIndex = 0;\r\n this.circleNumber++;\r\n }\r\n \r\n this.startDraw();\r\n \r\n \r\n })\r\n }\r\n //获取开始减速的下标\r\n private getSlowStart(){\r\n if(this.recordID < 0)return -1;\r\n let tmpIndex = this.getNodeIndexOFprize();\r\n if(tmpIndex < 4){\r\n return tmpIndex + 4;\r\n }else{\r\n return tmpIndex - 4\r\n }\r\n }\r\n //获取奖品节点下标\r\n getNodeIndexOFprize(){\r\n if(this.recordID < 0)return -1;\r\n for (let index = 0; index < this._boxArray.length; index++) {\r\n let element = this._boxArray[index];\r\n if(element.prizeID === this.recordID){\r\n return index;\r\n } \r\n }\r\n return -1;\r\n }\r\n //中奖节点闪烁\r\n twinkle(tmpNode){\r\n engine.Tween.removeTweens(tmpNode)\r\n let twinkleTime = 1;\r\n engine.Tween.get(tmpNode, {loop:true})\r\n .to({alpha:0}, 30)\r\n .to({alpha:1}, 30)\r\n .call(()=>{\r\n if(twinkleTime > 5){\r\n engine.Tween.removeTweens(tmpNode);\r\n engine.globalEvent.dispatchEvent('jiugong-turntable-change-over')\r\n return;\r\n }else{\r\n twinkleTime++;\r\n }\r\n })\r\n }\r\n setRecordID(prizeID){\r\n this.recordID = prizeID;\r\n }\r\n reset(){\r\n this._boxArray.forEach(element => {\r\n engine.Tween.removeTweens(element.getChildByName('checked'));\r\n });\r\n this._boxIndex = 0;//当前下标\r\n this.tweenTime = props.tweenTime || 200;//单个动画时间(毫秒)\r\n this.slowTweenTime = props.slowTweenTime || 200;\r\n this.circleNumber = 0;//圈数\r\n this.recordID = -1;//中奖奖品ID\r\n this.boxPrizeIndex = -1;//中奖奖品节点下标 \r\n this.slowDown = false;//是否开始缓速\r\n this.isStop = false;\r\n for (let index = 0; index < this._boxArray.length; index++) {\r\n let element = this._boxArray[index];\r\n element.getChildByName('checked').alpha = 0;\r\n }\r\n \r\n }\r\n\r\n}","\r\n/**\r\n * Created by rockyl on 2018/8/16.\r\n */\r\n\r\nimport {props} from \"../props\";\r\nimport { Turntable } from \"./turntable\";\r\n\r\n\r\n\r\n\r\n\r\nexport default class GameView extends engine.Container {\r\n\r\n\t\r\n\tprivate _hasSetup;\r\n\tprivate _turntable:Turntable;\r\n\tconstructor() {\r\n\t\tsuper();\t\r\n\t}\r\n\t setup(){\r\n\t\tif (this._hasSetup) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tthis._hasSetup = true;\r\n\t\t\r\n\t\tlet turntable = this._turntable = new Turntable();\r\n\t\tthis.addChild(turntable);\r\n\t}\r\n\tsetPrizeData(res){\r\n\t\tthis._turntable.initData(res);\r\n\t}\r\n\tstartDraw(){\r\n\t\tthis._turntable.startDraw();\r\n\t}\r\n\tsetRecordID(prizeID){\r\n\t\tthis._turntable.setRecordID(prizeID)\r\n\t}\r\n\treset(){\r\n\t\tthis._turntable.reset();\r\n\t}\r\n\tsetSetup(){\r\n\t\tthis._hasSetup = false;\r\n\t}\r\n}\r\n","\r\n\r\nimport { props } from '../props';\r\n\r\n\r\n/**\r\n * Created by rockyl on 2020-01-09.\r\n */\r\n\r\nimport GameView from \"./GameView\";\r\n\r\nexport class GameWrapper extends engine.Container {\r\n\tprivate _gameView: GameView;\r\n\r\n\tconstructor() {\r\n\t\tsuper();\r\n\r\n\t\tengine.globalEvent.addEventListener('jiugong-turntable-change-init', this.init, this);\r\n\t\tengine.globalEvent.addEventListener('jiugong-turntable-change-prizeData', this.initPrizeData, this);\r\n\r\n\t\tengine.globalEvent.addEventListener('jiugong-turntable-change-start', this.start, this);\r\n\r\n\t\tengine.globalEvent.addEventListener('jiugong-turntable-change-winPrize', this.winPrize, this);\r\n\t\tengine.globalEvent.addEventListener('jiugong-turntable-change-reset', this.reset, this);\r\n\t\tengine.globalEvent.addEventListener('jiugong-turntable-change-abnormal', this.reset, this);\r\n\t}\r\n\r\n\tinit(event: engine.Event) {\r\n\t\t//初始化场景\r\n\t\tlet gameView = this._gameView = new GameView();\r\n\t\tthis.addChild(gameView);\r\n\t\tthis._gameView.setup();\r\n\t}\r\n\tinitPrizeData(event: engine.Event){\r\n\t\tthis._gameView.setSetup();\r\n\t\tthis._gameView.setPrizeData(event.data.resources);\r\n\t}\r\n\r\n\t//开始抽奖\r\n\tstart(event: engine.Event){\r\n\t\tthis._gameView.startDraw();\r\n\t}\r\n\twinPrize(event: engine.Event){\r\n\t\tthis._gameView.setRecordID(event.data.prizeID)\r\n\t}\r\n\treset(){\r\n\t\tthis._gameView.reset();\r\n\t}\r\n\t// private visibilitychange(){\r\n\t// \tdocument.addEventListener('visibilitychange', function () {\r\n // if (document.visibilityState === 'hidden') {\r\n\t// \t\t\tconsole.log('放置后台');\r\n\t// \t\t\tengine.globalEvent.dispatchEvent('answer-game-visibilitychange',{hidden:true});\r\n // }\r\n // });\r\n\t// }\r\n}\r\n","/**\r\n * Created by rockyl on 2019-11-20.\r\n */\r\n\r\nimport {GameWrapper} from \"./game/GameWrapper\";\r\nimport {injectProps, prepareProps} from \"./props\";\r\n\r\nexport default function (props) {\r\n\tprepareProps();\r\n\tinjectProps(props);\r\n\r\n\tlet instance = new GameWrapper();\r\n\treturn instance;\r\n}\r\n"],"names":["__extends"],"mappings":";;;;;;UAKgB,UAAU,CAAC,IAAI;KAC9B,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;CACvD,CAAC;AAED,UAAgB,gBAAgB,CAAC,IAAI;KACpC,OAAO,UAAU,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;CACrD,CAAC;AAED;;CCTO,IAAI,KAAK,GAAQ,EAAE,CAAC;AAE3B,UAAgB,YAAY;KAC3B,IAAI,SAAS,GAAG,QAAQ,EAAE,CAAC;KAE3B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;CACrC,CAAC;AAED,UAAgB,WAAW,CAAC,CAAC;KAC5B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;CAC7B,CAAC;;;CCRD;KAA+BA,mCAAgB;KAoB3C;SAAA,YACI,iBAAO,SAEV;SArBO,iBA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AM,CAAC,WAAW,CAAC,gBAAgB,CAAC,mCAAmC,EAAE,KAAI,CAAC,KAAK,EAAE,KAAI,CAAC,CAAC;;MAC3F;KAED,0BAAI,GAAJ,UAAK,KAAmB;SAEvB,IAAI,QAAQ,GAAG,IAAI,CAAC,SAAS,GAAG,IAAI,QAAQ,EAAE,CAAC;SAC/C,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;SACxB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;MACvB;KACD,mCAAa,GAAb,UAAc,KAAmB;SAChC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;SAC1B,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;MAClD;KAGD,2BAAK,GAAL,UAAM,KAAmB;SACxB,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC;MAC3B;KACD,8BAAQ,GAAR,UAAS,KAAmB;SAC3B,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;MAC9C;KACD,2BAAK,GAAL;SACC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;MACvB;KASF,kBAAC;CAAD,CAAC,CA7CgC,MAAM,CAAC,SAAS,GA6ChD;;;iBCjDwB,KAAK;KAC7B,YAAY,EAAE,CAAC;KACf,WAAW,CAAC,KAAK,CAAC,CAAC;KAEnB,IAAI,QAAQ,GAAG,IAAI,WAAW,EAAE,CAAC;KACjC,OAAO,QAAQ,CAAC;CACjB,CAAC;;;;;;;;;"}
\ No newline at end of file
src/custom/jiugong-turntable-change/debug/props.js
0 → 100644
View file @
a9c7ec84
/**
* Created by rockyl on 2020-01-21.
*/
let
customModuleProps
=
{
};
src/custom/jiugong-turntable-change/meta.json
0 → 100644
View file @
a9c7ec84
{
"name"
:
"九宫格抽奖-更换奖池"
,
"desc"
:
"九宫格抽奖模块-更换奖池"
,
"props"
:
{
"horizontal"
:
{
"alias"
:
"横向间距"
,
"type"
:
"number"
,
"default"
:
1
},
"vertical"
:
{
"alias"
:
"纵向间距"
,
"type"
:
"number"
,
"default"
:
1
},
"circleNumber"
:
{
"alias"
:
"至少转的圈数"
,
"type"
:
"number"
,
"default"
:
3
},
"tweenTime"
:
{
"alias"
:
"单个奖品节点动画时间(毫秒)"
,
"type"
:
"number"
,
"default"
:
200
},
"slowTweenTime"
:
{
"alias"
:
"中奖后缓速递增时长"
,
"type"
:
"number"
,
"default"
:
200
},
"icon_width"
:
{
"alias"
:
"奖品图宽度"
,
"type"
:
"number"
,
"default"
:
110
},
"icon_height"
:
{
"alias"
:
"奖品图高度"
,
"type"
:
"number"
,
"default"
:
110
},
"icon_X"
:
{
"alias"
:
"奖品X轴偏移量(底框背景有透明)"
,
"type"
:
"number"
,
"default"
:
0
},
"icon_Y"
:
{
"alias"
:
"奖品Y轴偏移量(底框背景有透明)"
,
"type"
:
"number"
,
"default"
:
-20
},
"prizeName_size"
:
{
"alias"
:
"奖品名字字号"
,
"type"
:
"number"
,
"default"
:
30
},
"prizeName_Ypos"
:
{
"alias"
:
"奖品名字相对于底框的高度"
,
"type"
:
"number"
,
"default"
:
50
},
"prizeName_color"
:
{
"alias"
:
"奖品名字颜色值"
,
"type"
:
"string"
,
"default"
:
"#e8805d"
},
"prizeName_maxLength"
:
{
"alias"
:
"奖品名字最长显示长度"
,
"type"
:
"number"
,
"default"
:
8
},
"prizeName_retainLength"
:
{
"alias"
:
"奖品名字超过长度保留多少字数"
,
"type"
:
"number"
,
"default"
:
5
}
},
"assets"
:
[
{
"name"
:
"unchecked"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/3351a20f982fea1fbcbbb3b85bc03f6b547c8bbc.png"
,
"uuid"
:
"48dc9c00-92c3-4926-8d6b-9eb3e0d0668d"
,
"ext"
:
".png"
},
{
"name"
:
"checked"
,
"url"
:
" //yun.duiba.com.cn/aurora/assets/2a9f9ecc43eb912db553fa4685c1987a937f0198.png"
,
"uuid"
:
"1d7bc84d-689d-4a6a-a023-e4a7b9659083"
,
"ext"
:
".png"
}
],
"events"
:
{
"in"
:
{
"jiugong-turntable-change-init"
:
{
"alias"
:
"初始化"
,
"data"
:
{
}
},
"jiugong-turntable-change-prizeData"
:
{
"alias"
:
"奖品数据"
,
"data"
:
{
}
},
"jiugong-turntable-change-start"
:
{
"alias"
:
"开始"
,
"data"
:
{
}
},
"jiugong-turntable-change-winPrize"
:
{
"alias"
:
"中奖"
,
"data"
:
{
}
},
"jiugong-turntable-change-abnormal"
:
{
"alias"
:
"异常"
,
"data"
:
{
}
},
"jiugong-turntable-change-reset"
:
{
"alias"
:
"重置"
,
"data"
:
{
}
}
},
"out"
:
{
"jiugong-turntable-change-over"
:
{
"alias"
:
"结束"
,
"data"
:
{
}
}
}
}
}
\ No newline at end of file
src/custom/jiugong-turntable-change/src/game/GameView.ts
0 → 100644
View file @
a9c7ec84
/**
* Created by rockyl on 2018/8/16.
*/
import
{
props
}
from
"../props"
;
import
{
Turntable
}
from
"./turntable"
;
export
default
class
GameView
extends
engine
.
Container
{
private
_hasSetup
;
private
_turntable
:
Turntable
;
constructor
()
{
super
();
}
setup
(){
if
(
this
.
_hasSetup
)
{
return
;
}
this
.
_hasSetup
=
true
;
let
turntable
=
this
.
_turntable
=
new
Turntable
();
this
.
addChild
(
turntable
);
}
setPrizeData
(
res
){
this
.
_turntable
.
initData
(
res
);
}
startDraw
(){
this
.
_turntable
.
startDraw
();
}
setRecordID
(
prizeID
){
this
.
_turntable
.
setRecordID
(
prizeID
)
}
reset
(){
this
.
_turntable
.
reset
();
}
setSetup
(){
this
.
_hasSetup
=
false
;
}
}
src/custom/jiugong-turntable-change/src/game/GameWrapper.ts
0 → 100644
View file @
a9c7ec84
import
{
props
}
from
'../props'
;
/**
* Created by rockyl on 2020-01-09.
*/
import
GameView
from
"./GameView"
;
export
class
GameWrapper
extends
engine
.
Container
{
private
_gameView
:
GameView
;
constructor
()
{
super
();
engine
.
globalEvent
.
addEventListener
(
'jiugong-turntable-change-init'
,
this
.
init
,
this
);
engine
.
globalEvent
.
addEventListener
(
'jiugong-turntable-change-prizeData'
,
this
.
initPrizeData
,
this
);
engine
.
globalEvent
.
addEventListener
(
'jiugong-turntable-change-start'
,
this
.
start
,
this
);
engine
.
globalEvent
.
addEventListener
(
'jiugong-turntable-change-winPrize'
,
this
.
winPrize
,
this
);
engine
.
globalEvent
.
addEventListener
(
'jiugong-turntable-change-reset'
,
this
.
reset
,
this
);
engine
.
globalEvent
.
addEventListener
(
'jiugong-turntable-change-abnormal'
,
this
.
reset
,
this
);
}
init
(
event
:
engine
.
Event
)
{
//初始化场景
let
gameView
=
this
.
_gameView
=
new
GameView
();
this
.
addChild
(
gameView
);
this
.
_gameView
.
setup
();
}
initPrizeData
(
event
:
engine
.
Event
){
this
.
_gameView
.
setSetup
();
this
.
_gameView
.
setPrizeData
(
event
.
data
.
resources
);
}
//开始抽奖
start
(
event
:
engine
.
Event
){
this
.
_gameView
.
startDraw
();
}
winPrize
(
event
:
engine
.
Event
){
this
.
_gameView
.
setRecordID
(
event
.
data
.
prizeID
)
}
reset
(){
this
.
_gameView
.
reset
();
}
// private visibilitychange(){
// document.addEventListener('visibilitychange', function () {
// if (document.visibilityState === 'hidden') {
// console.log('放置后台');
// engine.globalEvent.dispatchEvent('answer-game-visibilitychange',{hidden:true});
// }
// });
// }
}
src/custom/jiugong-turntable-change/src/game/Turntable.ts
0 → 100644
View file @
a9c7ec84
import
{
getTextureByName
}
from
"./utils"
;
import
{
getStage
}
from
"./utils"
;
import
{
props
}
from
'../props'
;
export
class
Turntable
extends
engine
.
Container
{
private
_turnTableNode
:
engine
.
Container
;
private
_vertical_Y
=
props
.
vertical
||
20
;
//纵向间距
private
_horizontal_X
=
props
.
horizontal
||
20
;
//横向间距
private
_prizeIndex
=
0
;
private
_boxArray
=
[];
private
_boxIndex
=
0
;
//当前下标
private
tweenTime
=
props
.
tweenTime
||
200
;
//单个动画时间(毫秒)
private
slowTweenTime
=
props
.
slowTweenTime
||
200
;
private
circleNumber
=
0
;
//圈数
private
turntableOrder
=
[
1
,
2
,
3
,
5
,
8
,
7
,
6
,
4
];
private
recordID
=
-
1
;
//中奖奖品ID
private
boxPrizeIndex
=
-
1
;
//中奖奖品节点下标
private
slowDown
=
false
;
//是否开始缓速
private
isStop
=
false
;
private
_singleNodeWidth
;
//单个节点宽度
constructor
(){
super
()
}
public
initData
(
res
){
this
.
initTurntable
(
res
);
this
.
setNodeOrder
();
}
initTurntable
(
res
){
let
turnTableNode
=
null
;
if
(
this
.
_turnTableNode
){
this
.
removeChild
(
this
.
_turnTableNode
);
this
.
_turnTableNode
=
null
;
this
.
_boxArray
=
[];
this
.
_prizeIndex
=
0
;
this
.
_boxIndex
=
0
;
}
turnTableNode
=
this
.
_turnTableNode
=
new
engine
.
Container
();
//turnTableNode.y = 50;
this
.
addChild
(
turnTableNode
);
for
(
let
index_Y
=
0
;
index_Y
<
3
;
index_Y
++
)
{
for
(
let
index_X
=
0
;
index_X
<
3
;
index_X
++
)
{
if
(
index_X
==
1
&&
index_Y
==
1
)
continue
;
let
tmpNode
:
any
=
new
engine
.
Container
()
let
unchecked
=
this
.
getImage
(
'unchecked'
,
1
);
let
checked
=
this
.
getImage
(
'checked'
,
0
);
tmpNode
.
width
=
Math
.
max
(
unchecked
.
width
,
checked
.
width
);
this
.
_singleNodeWidth
=
this
.
_singleNodeWidth
?
this
.
_singleNodeWidth
:
tmpNode
.
width
;
tmpNode
.
height
=
Math
.
max
(
unchecked
.
height
,
checked
.
height
);
tmpNode
.
x
=
index_X
*
(
tmpNode
.
width
+
this
.
_horizontal_X
);
tmpNode
.
y
=
index_Y
*
(
tmpNode
.
height
+
this
.
_vertical_Y
);
tmpNode
.
addChild
(
unchecked
);
tmpNode
.
addChild
(
checked
);
let
prize
=
new
engine
.
Sprite
(
engine
.
Texture
.
fromImage
(
res
[
this
.
_prizeIndex
].
img
))
;
let
prizeID
=
res
[
this
.
_prizeIndex
].
id
;
prize
.
width
=
props
.
icon_width
;
prize
.
height
=
props
.
icon_height
;
prize
.
x
=
(
tmpNode
.
width
-
prize
.
width
)
/
2
+
props
.
icon_X
;
prize
.
y
=
(
tmpNode
.
height
-
prize
.
height
)
/
2
+
props
.
icon_Y
;
tmpNode
.
prizeID
=
prizeID
;
tmpNode
.
addChild
(
prize
);
let
titleLabel
=
new
engine
.
Label
();
titleLabel
.
fillColor
=
props
.
prizeName_color
;
titleLabel
.
size
=
props
.
prizeName_size
;
titleLabel
.
width
=
unchecked
.
width
;
titleLabel
.
textAlign
=
engine
.
TEXT_ALIGN
.
CENTER
;
titleLabel
.
x
=
0
;
titleLabel
.
y
=
props
.
prizeName_Ypos
;
titleLabel
.
text
=
this
.
fixTitle
(
res
[
this
.
_prizeIndex
].
name
);
tmpNode
.
addChild
(
titleLabel
)
this
.
_prizeIndex
++
;
this
.
_boxArray
.
push
(
tmpNode
);
turnTableNode
.
addChild
(
tmpNode
);
}
}
turnTableNode
.
x
=
(
750
-
(
this
.
_singleNodeWidth
*
3
+
this
.
_horizontal_X
*
2
))
/
2
;
}
setNodeOrder
(){
let
tmpNodeArray
=
[];
for
(
let
index
=
0
;
index
<
this
.
turntableOrder
.
length
;
index
++
)
{
let
order
=
this
.
turntableOrder
[
index
];
tmpNodeArray
.
push
(
this
.
_boxArray
[
order
-
1
]);
}
this
.
_boxArray
=
tmpNodeArray
;
}
fixTitle
(
name
){
if
(
!
name
){
return
""
}
if
(
name
.
split
(
""
).
length
<
props
.
prizeName_maxLength
){
return
name
}
let
n
=
""
for
(
let
i
=
0
;
i
<
props
.
prizeName_retainLength
;
i
++
){
n
+=
name
.
split
(
""
)[
i
]
}
n
+=
"..."
return
n
}
getImage
(
resName
,
alpha
){
let
tmpImage
=
new
engine
.
Sprite
(
getTextureByName
(
resName
));
tmpImage
.
x
=
0
tmpImage
.
y
=
0
tmpImage
.
alpha
=
alpha
;
tmpImage
.
name
=
resName
;
return
tmpImage
;
}
startDraw
(){
let
tmpCheckNode
=
this
.
_boxArray
[
this
.
_boxIndex
].
getChildByName
(
'checked'
);
if
(
this
.
isStop
){
engine
.
Tween
.
removeTweens
(
tmpCheckNode
);
return
}
if
(
this
.
slowDown
)
{
if
(
this
.
_boxIndex
!=
this
.
getNodeIndexOFprize
()){
this
.
tweenTime
+=
this
.
slowTweenTime
;
}
else
{
this
.
isStop
=
true
;
this
.
twinkle
(
tmpCheckNode
);
}
}
engine
.
Tween
.
get
(
tmpCheckNode
)
.
to
({
alpha
:
1
},
this
.
tweenTime
/
2
)
.
to
({
alpha
:
0
},
this
.
tweenTime
/
2
)
.
call
(()
=>
{
if
(
this
.
circleNumber
>=
props
.
circleNumber
&&
this
.
getSlowStart
()
==
this
.
_boxIndex
){
this
.
slowDown
=
true
;
}
this
.
_boxIndex
++
;
if
(
this
.
_boxIndex
>=
this
.
_boxArray
.
length
){
this
.
_boxIndex
=
0
;
this
.
circleNumber
++
;
}
this
.
startDraw
();
})
}
//获取开始减速的下标
private
getSlowStart
(){
if
(
this
.
recordID
<
0
)
return
-
1
;
let
tmpIndex
=
this
.
getNodeIndexOFprize
();
if
(
tmpIndex
<
4
){
return
tmpIndex
+
4
;
}
else
{
return
tmpIndex
-
4
}
}
//获取奖品节点下标
getNodeIndexOFprize
(){
if
(
this
.
recordID
<
0
)
return
-
1
;
for
(
let
index
=
0
;
index
<
this
.
_boxArray
.
length
;
index
++
)
{
let
element
=
this
.
_boxArray
[
index
];
if
(
element
.
prizeID
===
this
.
recordID
){
return
index
;
}
}
return
-
1
;
}
//中奖节点闪烁
twinkle
(
tmpNode
){
engine
.
Tween
.
removeTweens
(
tmpNode
)
let
twinkleTime
=
1
;
engine
.
Tween
.
get
(
tmpNode
,
{
loop
:
true
})
.
to
({
alpha
:
0
},
30
)
.
to
({
alpha
:
1
},
30
)
.
call
(()
=>
{
if
(
twinkleTime
>
5
){
engine
.
Tween
.
removeTweens
(
tmpNode
);
engine
.
globalEvent
.
dispatchEvent
(
'jiugong-turntable-change-over'
)
return
;
}
else
{
twinkleTime
++
;
}
})
}
setRecordID
(
prizeID
){
this
.
recordID
=
prizeID
;
}
reset
(){
this
.
_boxArray
.
forEach
(
element
=>
{
engine
.
Tween
.
removeTweens
(
element
.
getChildByName
(
'checked'
));
});
this
.
_boxIndex
=
0
;
//当前下标
this
.
tweenTime
=
props
.
tweenTime
||
200
;
//单个动画时间(毫秒)
this
.
slowTweenTime
=
props
.
slowTweenTime
||
200
;
this
.
circleNumber
=
0
;
//圈数
this
.
recordID
=
-
1
;
//中奖奖品ID
this
.
boxPrizeIndex
=
-
1
;
//中奖奖品节点下标
this
.
slowDown
=
false
;
//是否开始缓速
this
.
isStop
=
false
;
for
(
let
index
=
0
;
index
<
this
.
_boxArray
.
length
;
index
++
)
{
let
element
=
this
.
_boxArray
[
index
];
element
.
getChildByName
(
'checked'
).
alpha
=
0
;
}
}
}
\ No newline at end of file
src/custom/jiugong-turntable-change/src/game/utils.ts
0 → 100644
View file @
a9c7ec84
/**
* Created by rockyl on 2020-01-21.
*/
export
function
getTexture
(
uuid
)
{
return
engine
.
Texture
.
from
(
getAssetByUUID
(
uuid
).
uuid
);
}
export
function
getTextureByName
(
name
)
{
return
getTexture
(
engine
.
getAssetByName
(
name
).
uuid
);
}
export
function
playSound
(
name
)
{
engine
.
playSound
(
engine
.
getAssetByName
(
name
).
uuid
,
{
keep
:
true
});
}
export
function
getStage
(){
return
engine
.
gameStage
.
stage
;
}
\ No newline at end of file
src/custom/jiugong-turntable-change/src/index.ts
0 → 100644
View file @
a9c7ec84
/**
* 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/jiugong-turntable-change/src/props.ts
0 → 100644
View file @
a9c7ec84
/**
* 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