Commit 24e624ed authored by 汪欢's avatar 汪欢

2

parent a5553149
/**
* Created by rockyl on 2019-12-16.
*/
const customId = 'jiugong-turntable-change-automatic-rotate';
(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);
}
<!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
/**
* Created by rockyl on 2020-01-21.
*/
const assets = [
];
function loadAssets(customModuleAssets, onProgress, onComplete){
return engine.loadAssets(assets.concat(...customModuleAssets), onProgress, onComplete);
}
"use strict";var tslib=require("tslib");function getTexture(e){return engine.Texture.from(getAssetByUUID(e).uuid)}function getTextureByName(e){return getTexture(engine.getAssetByName(e).uuid)}var props={};function prepareProps(){var e=getProps();engine.injectProp(props,e)}function injectProps(e){engine.injectProp(props,e)}var Turntable=function(t){function e(){var e=t.call(this)||this;return e._vertical_Y=props.vertical||20,e._horizontal_X=props.horizontal||20,e._prizeIndex=0,e._boxArray=[],e._boxIndex=0,e.tweenTime=props.tweenTime||200,e.slowTweenTime=props.slowTweenTime||200,e.circleNumber=0,e.turntableOrder=[1,2,3,5,8,7,6,4],e.recordID=-1,e.boxPrizeIndex=-1,e.slowDown=!1,e.isStop=!1,e.automaticFlag=!0,e}return tslib.__extends(e,t),e.prototype.initData=function(e){this.initTurntable(e),this.setNodeOrder()},e.prototype.initTurntable=function(e){var t=null;this._turnTableNode&&(this.removeChild(this._turnTableNode),this._turnTableNode=null,this._boxArray=[],this._prizeIndex=0,this._boxIndex=0),t=this._turnTableNode=new engine.Container,this.addChild(t);for(var i=0;i<3;i++)for(var n,r,o,a,s,h,p=0;p<3;p++){1==p&&1==i||(n=new engine.Container,r=this.getImage("unchecked",1),o=this.getImage("checked",0),n.width=Math.max(r.width,o.width),this._singleNodeWidth=this._singleNodeWidth?this._singleNodeWidth:n.width,n.height=Math.max(r.height,o.height),n.x=p*(n.width+this._horizontal_X),n.y=i*(n.height+this._vertical_Y),n.addChild(r),n.addChild(o),a=new engine.Sprite(engine.Texture.fromImage(e[this._prizeIndex].img)),s=e[this._prizeIndex].id,a.width=props.icon_width,a.height=props.icon_height,a.x=(n.width-a.width)/2+props.icon_X,a.y=(n.height-a.height)/2+props.icon_Y,n.prizeID=s,n.addChild(a),(h=new engine.Label).fillColor=props.prizeName_color,h.size=props.prizeName_size,h.width=r.width,h.textAlign=engine.TEXT_ALIGN.CENTER,h.x=0,h.y=props.prizeName_Ypos,h.text=this.fixTitle(e[this._prizeIndex].name),n.addChild(h),this._prizeIndex++,this._boxArray.push(n),t.addChild(n))}t.x=(750-(3*this._singleNodeWidth+2*this._horizontal_X))/2},e.prototype.setNodeOrder=function(){for(var e=[],t=0;t<this.turntableOrder.length;t++){var i=this.turntableOrder[t];e.push(this._boxArray[i-1])}this._boxArray=e},e.prototype.fixTitle=function(e){if(!e)return"";if(e.split("").length<props.prizeName_maxLength)return e;for(var t="",i=0;i<props.prizeName_retainLength;i++)t+=e.split("")[i];return t+="..."},e.prototype.getImage=function(e,t){var i=new engine.Sprite(getTextureByName(e));return i.x=0,i.y=0,i.alpha=t,i.name=e,i},e.prototype.automaticRotate=function(){var e=this;console.log("enter the automatic rotate");var t=this._boxArray[this._boxIndex].getChildByName("checked");if(this.tweenTime=1e3,!this.automaticFlag)return this._boxIndex=0,this.tweenTime=props.tweenTime||200,void engine.Tween.removeTweens(t);engine.Tween.get(t).to({alpha:1},this.tweenTime/2).to({alpha:0},this.tweenTime/2).call(function(){e._boxIndex++,e._boxIndex>=e._boxArray.length&&(e._boxIndex=0),e.automaticRotate()})},e.prototype.startDraw=function(){var e=this;this.automaticFlag=!1;var t=this._boxArray[this._boxIndex].getChildByName("checked");this.isStop?engine.Tween.removeTweens(t):(this.slowDown&&(this._boxIndex!=this.getNodeIndexOFprize()?this.tweenTime+=this.slowTweenTime:(this.isStop=!0,this.twinkle(t),this.automaticFlag=!0)),engine.Tween.get(t).to({alpha:1},this.tweenTime/2).to({alpha:0},this.tweenTime/2).call(function(){e.circleNumber>=props.circleNumber&&e.getSlowStart()==e._boxIndex&&(e.slowDown=!0),e._boxIndex++,e._boxIndex>=e._boxArray.length&&(e._boxIndex=0,e.circleNumber++),e.startDraw()}))},e.prototype.getSlowStart=function(){if(this.recordID<0)return-1;var e=this.getNodeIndexOFprize();return e<4?e+4:e-4},e.prototype.getNodeIndexOFprize=function(){if(this.recordID<0)return-1;for(var e=0;e<this._boxArray.length;e++){if(this._boxArray[e].prizeID===this.recordID)return e}return-1},e.prototype.twinkle=function(e){engine.Tween.removeTweens(e);var t=1;engine.Tween.get(e,{loop:!0}).to({alpha:0},30).to({alpha:1},30).call(function(){return 5<t?(engine.Tween.removeTweens(e),void engine.globalEvent.dispatchEvent("jiugong-turntable-change-over")):void t++})},e.prototype.setRecordID=function(e){this.recordID=e},e.prototype.reset=function(){this._boxArray.forEach(function(e){engine.Tween.removeTweens(e.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=!1,this.isStop=!1,this.automaticFlag=!0;for(var e=0;e<this._boxArray.length;e++){this._boxArray[e].getChildByName("checked").alpha=0}},e}(engine.Container),GameView=function(e){function t(){return e.call(this)||this}return tslib.__extends(t,e),t.prototype.setup=function(){var e;this._hasSetup||(this._hasSetup=!0,e=this._turntable=new Turntable,this.addChild(e))},t.prototype.setPrizeData=function(e){this._turntable.initData(e),this._turntable.automaticRotate()},t.prototype.startDraw=function(){this._turntable.startDraw()},t.prototype.setRecordID=function(e){this._turntable.setRecordID(e)},t.prototype.reset=function(){this._turntable.reset()},t.prototype.setSetup=function(){this._hasSetup=!1},t}(engine.Container),GameWrapper=function(t){function e(){var e=t.call(this)||this;return engine.globalEvent.addEventListener("jiugong-turntable-change-init",e.init,e),engine.globalEvent.addEventListener("jiugong-turntable-change-prizeData",e.initPrizeData,e),engine.globalEvent.addEventListener("jiugong-turntable-change-start",e.start,e),engine.globalEvent.addEventListener("jiugong-turntable-change-winPrize",e.winPrize,e),engine.globalEvent.addEventListener("jiugong-turntable-change-reset",e.reset,e),engine.globalEvent.addEventListener("jiugong-turntable-change-abnormal",e.reset,e),e}return tslib.__extends(e,t),e.prototype.init=function(e){var t=this._gameView=new GameView;this.addChild(t),this._gameView.setup()},e.prototype.initPrizeData=function(e){this._gameView.setSetup(),this._gameView.setPrizeData(e.data.resources)},e.prototype.start=function(e){this._gameView.startDraw()},e.prototype.winPrize=function(e){this._gameView.setRecordID(e.data.prizeID)},e.prototype.reset=function(){this._gameView.reset()},e}(engine.Container);function index(e){return prepareProps(),injectProps(e),new GameWrapper}module.exports=index;
/**
* Created by rockyl on 2020-01-21.
*/
let customModuleProps = {
};
{
"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
/**
* 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);
this._turntable.automaticRotate();
}
startDraw(){
this._turntable.startDraw();
}
setRecordID(prizeID){
this._turntable.setRecordID(prizeID)
}
reset(){
this._turntable.reset();
}
setSetup(){
this._hasSetup = false;
}
}
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});
// }
// });
// }
}
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 automaticFlag = true;
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;
}
automaticRotate(){
console.log('enter the automatic rotate');
let tmpCheckNode = this._boxArray[this._boxIndex].getChildByName('checked');
this.tweenTime = 1000;
if(!this.automaticFlag){
this._boxIndex = 0;
this.tweenTime = props.tweenTime || 200;
engine.Tween.removeTweens(tmpCheckNode);return}
engine.Tween.get(tmpCheckNode)
.to({alpha:1},this.tweenTime/2)
.to({alpha:0},this.tweenTime/2)
.call(()=>{
this._boxIndex ++;
if(this._boxIndex >= this._boxArray.length){
this._boxIndex = 0;
// this.circleNumber++;
}
this.automaticRotate();
})
}
startDraw(){
this.automaticFlag = false;
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);
this.automaticFlag = true;
}
}
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;
this.automaticFlag = true;
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
/**
* 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
/**
* 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;
}
/**
* 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);
}
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