Commit bb769353 authored by lujinlei's avatar lujinlei

Merge branch 'dev' of http://gitlab2.dui88.com/laoqifeng/zeroing-libs into dev

parents ec98a15d db73236a
This diff is collapsed.
/**
* 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);
}
export class Buried {
appId;
consumerId;
oaId;
/**
* 初始化
*/
static init() {
// appId = window["appId"];
// oaId = window["projectId"];
this.appId = window.CFG.appID;
this.oaId = window.CFG.projectId;
}
/**
* 创建dpm埋点数据
* @param {string} dpm 点击埋点
* @param {string} dcm 曝光埋点
* @param {string} embedDomain 埋点域名
* @returns {{dpm: string; consumerId: number; domain: string; appId: number}}
*/
static createExposure(dpm, dcm, embedDomain = '//embedlog.duiba.com.cn') {
let dom
dom = "1.0.0.0"
const exposure = {
dpm: dpm,
dcm: dcm,
// dom: dom,
appId: Buried.appId,
domain: embedDomain
};
return exposure;
}
/**
* dpm拼接
* @param pageId 页面ID
* @param area 区域
* @param dpm 埋点号
* @returns {string}
*/
static connectDpm(pageId, area, dpm) {
return Buried.appId + '.' + pageId + '.' + area + '.' + dpm;
}
/**
* dcm拼接
* @param typeId 类型ID
* @param contentInfo 内容信息
* @param dcm 埋点号
* @returns {string}
*/
static connectDcm(typeId, contentInfo, dcm) {
return typeId + '.' + Buried.oaId + '.' + contentInfo + '.' + dcm;
}
/**
* 插件dcm拼接
* @param plugId 插件ID
* @param type 1 活动工具 2 主会场 4 楼层 5 游戏 7 子页面
* @returns {string}
*/
static connectPlugDcm(plugId, type) {
return 212 + '.' + plugId + '.' + type + '.' + Buried.oaId;
}
/**
* 活动dcm拼接
* @param type 1 活动工具 2 主会场 4 楼层 5 游戏 7 子页面
* @returns {string}
*/
static connectActivityDcm(type) {
return 202 + '.' + Buried.oaId + '.' + type + '.' + Buried.oaId;
}
}
import { Buried } from "./Buried";
export class NetBuried {
// constructor() { }
exposure = []
dpm = []
dcm = []
showLog(i, d) {
var appId = window.CFG.appID || 77208;
var oaId = window.CFG.projectId;
if (d) {
this.dpm[i] = `${appId}.110.${i}.${d}`;
} else {
this.dpm[i] = `${appId}.110.${i}.1`;
}
this.dcm[i] = `202.${oaId}.0.0`;
this.exposure[i] = Buried.createExposure(this.dpm[i], this.dcm[i]);
this._showLog(this.exposure[i]);
}
clickLog(i, d) {
var appId = window.CFG.appID || 77208;
var oaId = window.CFG.projectId;
if (d) {
this.dpm[i] = `${appId}.110.${i}.${d}`;
} else {
this.dpm[i] = `${appId}.110.${i}.1`;
}
this.dcm[i] = `202.${oaId}.0.0`;
this.exposure[i] = Buried.createExposure(this.dpm[i], this.dcm[i]);
this._clickLog(this.exposure[i]);
}
/**
* 兑吧点击埋点
* @param {IExposureData} exposure
*/
_clickLog(exposure) {
const net = {
name: 'clickLog',
uri: '/log/click',
type: 'get',
dataType: 'jsonp',
param: exposure,
callback: null,
hideMsg: true
};
this.send(net);
}
/**
* 兑吧曝光埋点
* @param {IExposureData} exposure
*/
_showLog(exposure) {
const net = {
name: 'showLog',
uri: exposure.domain + '/exposure/standard',
type: 'get',
dataType: 'jsonp',
param: exposure,
callback: null,
hideMsg: true
};
this.send(net);
}
/**
* 发送请求
* @param net
*/
send(net) {
let realUrl = net.uri;
//url加参数等特殊需求(例如再玩一次需要在dostart接口的url上加埋点)
if (net.addUrl) {
realUrl += net.addUrl;
}
window['$'].ajax({
type: net.type,
url: realUrl,
dataType: net.dataType,
data: net.param,
async: true,
success: (result) => {
},
error: (message) => {
}
});
}
}
\ No newline at end of file
/**
* Created by renjianfeng on 2020-03-13.
*/
const customId = 'superman';
(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('pictures-setProjectId',{projectId:"wegg",appId:"77205"})
// },1000);
// setTimeout(() => {
// engine.globalEvent.dispatchEvent('pictures-ActLabel',{type:2})
// },1000);
// setTimeout(() => {
// engine.globalEvent.dispatchEvent('pictures-ActLabel',{type:3})
// },2000);
// // const d = engine.gameStage.sceneContainer.getChildAt(0);
// // engine.gameStage.sceneContainer.getChildAt(0).x = (d.stage.width-props.W)/2;
// // engine.gameStage.sceneContainer.getChildAt(0).y = (d.stage.height-props.H)/2;
// }, 3000);
// setTimeout(()=>{
// engine.globalEvent.dispatchEvent("pictures-reset",{})
// },10000);
// setTimeout(() => {
// engine.globalEvent.dispatchEvent('pictures-start', {
// picUrl: "http://yun.duiba.com.cn/aurora/assets/e1593b97c27077b85b92f7eaaeae1ed64a1eb79a.png",
// // picUrl: "http://yun.duiba.com.cn/aurora/assets/d23e73d37ec01931e48cbd0a4095367044c5675c.png"
// blockUrl: "888"
// });
// }, 30*1000);
});
// engine.globalEvent.addEventListener('pictures-game-fail', (e) => {
// console.log(e.type, e.data);
// });
// engine.globalEvent.addEventListener('pictures-game-success', (e) => {
// console.log(e.type, e.data);
// });
}
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>test</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: gray;
}
.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.1de84ff79dba19e949088de63aa75af51a515e5c.js"></script>
<script crossorigin="anonymous" src="//yun.duiba.com.cn/editor/zeroing/libs/svga.fd3923ae6e664251ca7981801a65809cc5f36bc3.js"></script>
<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.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
/**
* Created by rockyl on 2020-01-21.
*/
const assets = [
{
"name": "玩家icon",
"url": "//yun.duiba.com.cn/aurora/assets/5b3e30496b2d9fdafb0cf3835fd6704ce10e45b4.png",
"uuid": "888",
"ext": ".png"
},
{
"name": "雨滴",
"url": "//yun.duiba.com.cn/aurora/assets/8564c8c9be3aead71b05a0bab8d7d07ac3f778a1.png",
"uuid": "264a6192-d7bf-45e8-8f15-6ba2c439a532",
"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/93d37b4a0e367e80e375308a6b4414d72d7666fc.svga",
"uuid": "b521bf94-20e1-44dd-8eca-d24996cbaeae",
"ext": ".svga"
},
{
"name": "炸弹",
"url": "//yun.duiba.com.cn/aurora/assets/4dd18f0689c663bbcf710a7afc4d929084d97d36.svga",
"uuid": "322edf39-805b-4e84-9d07-5573dfeebc0e",
"ext": ".svga"
},
{
"name": "玩家",
"url": "//yun.duiba.com.cn/aurora/assets/b66300c5d4f27134b0aac3dc90a3220e8ae572eb.svga",
"uuid": "71d8dcbc-3931-471a-b585-b3ae01b25aa6",
"ext": ".svga"
}
];
function loadAssets(customModuleAssets, onProgress, onComplete){
return engine.loadAssets(assets.concat(...customModuleAssets), onProgress, onComplete);
}
This diff is collapsed.
This diff is collapsed.
/**
* Created by rockyl on 2020-01-21.
*/
let customModuleProps = {
};
{
"name": "蛋黄超人自定义模块",
"desc": "蛋黄超人自定义模块1.0",
"props": {
"QTextStrArr":{
"alias":"问题文案组,用逗号隔开,不填为默认",
"type":"string",
"default":"1、什么是筑梦空间?,2、金币是什么?,3、怎么获得金币?,4、如何更改用户昵称?,5、个人信息可以进行哪些操作?,6、通过二维码添加好友之后在哪里查看?,7、我的勋章是什么?,8、任务有哪些分类?"
},
"ATextStrArr":{
"alias":"答案文案组,用逗号隔开,不填为默认",
"type":"string",
"default":"筑梦空间带给用户吃喝玩乐的不同体验,在这里你可以进行生活缴费、体验本地优惠、建设我的庄园、畅玩游戏中心等等。,金币是筑梦空间中的虚拟货币,用户可以使用金币游玩游戏、种植植物、兑换实物,同时金币可以按一定比例兑换波豆,波豆可以在波豆商城兑换更丰富的商品。,用户可以通过签到、任务、参与活动以及我的庄园果实售卖方式获得金币。,用户可以点击左上角个人信息按钮进入个人信息弹窗,点击昵称旁的修改按钮对昵称进行修改。,用户可以在个人信息页面进行修改昵称、修改头像、兑换波豆、查询金币明细、扫二维码添加好友等操作。,用户A通过扫描用户B的二维码进入活动之后,双方即绑定为好友,可以排行榜-好友排行榜进行查看。,当用户在筑梦空间的各种行为动作达到一定次数时,会点亮相应的激励勋章。,任务中分为一次性任务、永久开放任务和周期更新任务,一次性任务为完成一次或多次后消失的任务,如浏览车主服务任务、升级房屋任务;永久开放任务为一直可以完成并获得奖励的任务,如邀请好友任务;周期任务为以周期(每日/周/月)为单位进行更新的任务,如分享筑梦空间、去商店购买种子任务,积极完成任务可以获得更多金币。"
},
"ACTTextStrArr":{
"alias":"互动文案组,用逗号隔开,不填为默认",
"type":"string",
"default":"主人你多久没来看我了,我好想你啊,Whoooo,主人你太棒了,主人,果子都成熟了,赶紧去采摘吧,主人,有空地可以种植哦,赶紧去吧!"
},
"type":{
"alias":"类型,用于区分所在场景,用于埋点,0:首页,1:庄园",
"type":"number",
"default":"0"
}
},
"assets": [
{
"name": "大对话泡",
"url": "//yun.duiba.com.cn/aurora/assets/a3d49f913ee300b2834260967010a2e7b2d5c265.png",
"uuid": "21d8b7ca-6ed3-44e5-ada0-f0433f471ac9",
"ext": ".png"
},
{
"name": "小对话泡",
"url": "//yun.duiba.com.cn/aurora/assets/c034f14785a2a36dce266cef0f46bd783ad03cb2.png",
"uuid": "9e4d1860-4762-4ac1-bc44-b3dd8fb307a6",
"ext": ".png"
},
{
"name": "蛋黄超人关闭按钮",
"url": "//yun.duiba.com.cn/aurora/assets/7a346d4e2c2cbce5ab3ac0a74e481525b048fcdd.png",
"uuid": "76f2c800-2174-4a90-ad6d-5853e95eb144",
"ext": ".png"
},
{
"name": "返回按钮",
"url": "//yun.duiba.com.cn/aurora/assets/8f55741c71b2aa7babe5cc517707cdd51b33c3d9.png",
"uuid": "2a555da9-dc05-4046-a5fb-551f0c2692fa",
"ext": ".png"
},
{
"name":"蛋黄超人icon",
"url":"//yun.duiba.com.cn/aurora/assets/baeec26a873006fabf031af8c918153384a732ef.png",
"uuid":"d5df1198-2cad-42e0-a197-fd56a2502d99",
"ext":".png"
},
{
"name":"蛋黄超人名称",
"url":"//yun.duiba.com.cn/aurora/assets/11b02c3908bcb8d685610caafdab9785fac5fccf.png",
"uuid":"fef58cbd-9c24-4216-896a-2799011df1dc",
"ext":".png"
},
{
"name":"右箭头",
"url":"//yun.duiba.com.cn/aurora/assets/8be77ba8ce699c4d302cd58e4d3be06919ac732f.png",
"uuid":"8546dcf7-a6e8-4ba2-89f7-b929118e473a",
"ext":".png"
},
{
"name":"常规呼吸动作",
"url":"//yun.duiba.com.cn/aurora/assets/adc7212454ea1d84ac5824982a57f37d2e745b54.svga",
"uuid":"ba2f8259-71b5-49ac-8310-08538a6b5d07",
"ext":".svga"
},
{
"name":"招手",
"url":"//yun.duiba.com.cn/aurora/assets/cf78c2f55369b597dfc744159687dc255f18a2b4.svga",
"uuid":"97de87e9-2ea4-4a31-9986-25edcd807c05",
"ext":".svga"
}
],
"events": {
"in": {
"pictures-ActLabel":{
"alias":"互动显示",
"data":{
"type":"0:24小时未登录互动,1:任务完成互动,2:农作物成熟互动,3:有土地未种植互动"
}
},
"pictures-setProjectId":{
"alias":"设置星速台id与appid",
"data":{
"projectId":"默认为'0'",
"appId":"默认为'0'"
}
}
},
"out": {
"pictures-end": {
"alias": "结束"
}
}
}
}
\ No newline at end of file
// import { DataManager } from './../manager/DataManager';
import { IExposureData } from './IExposureData';
// import { IExposureData } from '..';
export class Buried {
public static appId: string = '0';
public static consumerId: number;
public static oaId: string = "0";
/**
* 初始化
*/
public static init(): void {
// if(DataManager.ins.gameCfgData) {
// this.appId = DataManager.ins.gameCfgData.appInfo.appId;
// this.consumerId = DataManager.ins.getInfoData.consumerId;
// this.oaId = DataManager.ins.gameCfgData.gameInfo.oaId;
// } else if(DataManager.ins.customCfgData){
// this.appId = DataManager.ins.customCfgData.appId;
// this.consumerId = DataManager.ins.customCfgData.consumerId;
// this.oaId = DataManager.ins.customCfgData.oaId ;
// } else if(DataManager.ins.petIndexData && DataManager.ins.petIndexData.appId && DataManager.ins.petIndexData.activityId){
// this.appId = DataManager.ins.petIndexData.appId;
// this.consumerId = DataManager.ins.petIndexData.consumerId;
// this.oaId = DataManager.ins.petIndexData.activityId ;
// } else if(DataManager.ins.petsIndexData && DataManager.ins.petsIndexData.appId && DataManager.ins.petsIndexData.activityId){
// this.appId = DataManager.ins.petsIndexData.appId;
// this.consumerId = DataManager.ins.petsIndexData.consumerId;
// this.oaId = DataManager.ins.petsIndexData.activityId ;
// }
}
/**
* 创建dpm埋点数据
* @param {string} dpm 点击埋点
* @param {string} dcm 曝光埋点
* @param {string} embedDomain 埋点域名
* @returns {{dpm: string; consumerId: number; domain: string; appId: number}}
*/
public static createExposure(dpm: string, dcm: string, embedDomain = '//embedlog.duiba.com.cn'): IExposureData {
const exposure: any = {
dpm: dpm,
dcm: dcm,
appId: Buried.appId,
domain: embedDomain
};
return exposure;
}
/**
* dpm拼接
* @param pageId 页面ID
* @param area 区域
* @param dpm 埋点号
* @returns {string}
*/
public static connectDpm(pageId: number, area: number, dpm: number): string {
return Buried.appId + '.' + pageId + '.' + area + '.' + dpm;
}
/**
* dcm拼接
* @param typeId 类型ID
* @param contentInfo 内容信息
* @param dcm 埋点号
* @returns {string}
*/
public static connectDcm(typeId: number, contentInfo: number, dcm: number): string {
return typeId + '.' + Buried.oaId + '.' + contentInfo + '.' + dcm;
}
/**
* 插件dcm拼接
* @param plugId 插件ID
* @param type 1 活动工具 2 主会场 4 楼层 5 游戏 7 子页面
* @returns {string}
*/
public static connectPlugDcm(plugId: number, type: number): string {
return 212 + '.' + plugId + '.' + type + '.' + Buried.oaId;
}
/**
* 活动dcm拼接
* @param type 1 活动工具 2 主会场 4 楼层 5 游戏 7 子页面
* @returns {string}
*/
public static connectActivityDcm(type: number): string {
return 202 + '.' + Buried.oaId + '.' + type + '.' + Buried.oaId;
}
}
export class GTime {
/**
* 获取当前时间戳
* @returns {number}
*/
public static getTimestamp(): number {
return new Date().getTime();
}
/**
* 转化时分秒
* @param time
*/
public static GetTimeHMS(time:number):string{
let t;
let h = Math.floor(time / 3600);
let hstr = h > 9 ? h : '0' + h;
let m = Math.floor((time % 3600) / 60);
let mstr = m > 9 ? m : '0' + m;
let s = Math.floor(time % 60);
let sstr = s > 9 ? s : '0' + s;
t = hstr + ':' + mstr + ':' + sstr;
return t;
}
/**
* 转化分秒
* @param time
*/
public static GetTimeMS(time:number):string{
let t;
let m = Math.floor((time % 3600) / 60);
let mstr = m > 9 ? m : '0' + m;
let s = Math.floor(time % 60);
let sstr = s > 9 ? s : '0' + s;
t = mstr + ':' + sstr;
return t;
}
}
\ No newline at end of file
This diff is collapsed.
// import GameView from "./GameView";
import { injectProps } from "../props";
import TestView from './TestView'
import { Buried } from "./Buried";
export class GameWrapper extends engine.Container{
// private _gameView:GameView
private _testView:TestView
constructor(){
super();
// engine.globalEvent.addEventListener('pictures-start', this.start, this);
// engine.globalEvent.addEventListener('pictures-stop', this.stop, this);
engine.globalEvent.addEventListener("pictures-setProjectId",this.setProjectId,this);
//创建实例
// let gameView = this._gameView = new GameView();
// this.addChild(gameView);
let testView = this._testView = new TestView();
this.addChild(testView);
}
setProjectId(event:engine.Event){
injectProps(event.data);
Buried.oaId = event.data.projectId;
Buried.appId = event.data.appId;
}
start(event: engine.Event) {
injectProps(event.data);
// this._status = 1;
// this._testView.start();
}
stop(event: engine.Event) {
// this._testView.stop();
}
}
\ No newline at end of file
/**
*Created by cuiliqiang on 2018/3/1
* 埋点信息
*/
export interface IExposureData {
activityId?: number;
activityUseType?: string;
advertId?: number;
appId: number;
consumerId: number;
dcm: string;
domain: string;
dpm: string;
ip?: string;
isEmbed?: boolean;
materialId?: number;
orderId?: string;
os?: string;
}
\ No newline at end of file
export interface INetData {
//名字
name: any;
//地址
uri: string;
//接口类型 get、post等
type: string;
//返回数据类型
dataType: string;
//参数
param: any;
//回调
callback: Function;
//轮询次数
pollingCount?: number;
//轮询条件检查
pollingCheck?: Function;
//url拼接内容
addUrl?: string;
//是否显示错误提示
hideMsg?: boolean;
}
\ No newline at end of file
This diff is collapsed.
import {getTexture, createSvga, showLog, clickLog} from './utils'
import QAText from './QAText';
import {getlogItem} from './getlogItem';
import { props } from '../props';
export default class TestView extends engine.Container{
worldTime:number;
supermanImg:engine.Image;
qaisOpen:boolean = false;
QAText:QAText;
breathSvga:svga.Svga;
waveSvga:svga.Svga;
rect:engine.Rect;
constructor(){
super()
this.addEventListener(engine.Event.ADDED_TO_STAGE, this.setup, this);
}
setup(){
var that = this;
that.removeEventListener(engine.Event.ADDED_TO_STAGE, this.setup, this)
that.rect = new engine.Rect();
that.rect.fillColor = "#000000";
that.rect.alpha = 0.7;
that.rect.width = 2000;
that.rect.height = 2000;
that.rect.visible = false;
that.addChild(that.rect);
that.breathSvga = createSvga("常规呼吸动作");
that.waveSvga = createSvga("招手");
that.waveSvga.visible = false;
that.breathSvga.visible = true;
that.breathSvga.mouseEnabled = that.waveSvga.mouseEnabled = true;
that.addChild(that.breathSvga);
that.addChild(that.waveSvga);
that.breathSvga.x = that.waveSvga.x = engine.gameStage.stage.width - 178*0.7;
that.breathSvga.y = that.waveSvga.y = engine.gameStage.stage.height/3*2-60;
that.breathSvga.gotoAndPlay(1);
// that.breathSvga.scale = 0.6;
// that.waveSvga.scale = 0.6;
that.breathSvga.scaleX = that.breathSvga.scaleY = 0.7;
that.waveSvga.scaleX = that.waveSvga.scaleY = 0.7;
that.QAText = new QAText();
that.addChild(that.QAText);
that.QAText.setBigBgPositon(engine.gameStage.stage.width - that.QAText.getBigBgSize().w-35,engine.gameStage.stage.height/3*2-60 - that.QAText.getBigBgSize().h)
that.QAText.setSmallBgPositon(engine.gameStage.stage.width - that.QAText.getSmallBgSize().w-35,engine.gameStage.stage.height/3*2-60 - that.QAText.getSmallBgSize().h)
that.addEvnt();
}
addEvnt(){
var that = this;
// that.supermanImg.addEventListener(engine.MouseEvent.CLICK,that.touchSuperManImg,that);
that.breathSvga.addEventListener(engine.MouseEvent.CLICK,that.touchSuperManImg,that);
that.waveSvga.addEventListener(engine.MouseEvent.CLICK,that.touchSuperManImg,that);
engine.globalEvent.addEventListener("pictures-ActLabel",that.showActLabelGroup,that);
engine.globalEvent.addEventListener("pictures-supermanAnim",that.supermanAnim,that);
engine.globalEvent.addEventListener("hideRect",()=>{that.rect.visible = false},that);
}
/**蛋黄超人动效 */
supermanAnim(){
}
/**点击蛋黄超人 */
touchSuperManImg(e:engine.MouseEvent){
console.log("点击蛋黄超人")
var that = this;
if(that.QAText.visible) return;
if(props.type == 0){
clickLog(getlogItem(17))
}else if(props.type == 1){
clickLog(getlogItem(51))
}
//蛋黄超人动效
that.showWaveSvga();
that.QAText.showQLabelGroup(null);
that.rect.visible = true;
}
/**展示互动文案组 */
showActLabelGroup(e:engine.Event){
var that = this;
//蛋黄超人动效
that.showWaveSvga();
that.QAText.showActLabelGroup(parseInt(e.data.type))
}
showWaveSvga(){
var that = this;
that.breathSvga.visible = false;
that.waveSvga.visible = true;
that.waveSvga.play(false,false);
that.waveSvga.once(engine.Event.END_FRAME,()=>{
that.waveSvga.visible = false;
that.breathSvga.gotoAndPlay(1)
that.breathSvga.visible = true;
},that)
}
}
\ No newline at end of file
import { Buried } from "./Buried";
import {props} from '../props'
export const getlogItem = (i) =>{
const Dpm = Buried.connectDpm(110, i, 1); // 点击埋点
const Dcm = Buried.connectDcm(202, 0, 0); // 曝光埋点
return Buried.createExposure(Dpm, Dcm);
};
\ No newline at end of file
{
"a":1
}
\ No newline at end of file
/**
* Created by rockyl on 2020-01-21.
*/
import {IExposureData} from './IExposureData'
import {INetData} from './INetData'
import { GTime } from './GTime';
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 createSvga(name, anchorName?) {
let inst = new svga.Svga();
inst.source = 'asset://' + engine.getAssetByName(name).uuid;
return inst;
}
export function getIndexFromRC(row,col,maxCol){
let index;
index = row * maxCol + col ;
return index
}
export function getRandomArray(array){
array.sort(function() {
return .5 - Math.random();
});
}
/**
* 兑吧点击埋点
* @param {IExposureData} exposure
*/
export function clickLog(exposure: IExposureData): void {
const net: INetData = {
name: 'clickLog',
uri: '/log/click',
type: 'get',
dataType: 'jsonp',
param: exposure,
callback: null,
hideMsg: true
};
send(net);
}
/**
* 兑吧曝光埋点
* @param {IExposureData} exposure
*/
export function showLog(exposure: IExposureData): void {
const net: INetData = {
name: 'showLog',
uri: exposure.domain + '/exposure/standard',
type: 'get',
dataType: 'jsonp',
param: exposure,
callback: null,
hideMsg: true
};
send(net);
}
/**
* 发送请求
* @param net
*/
export function send(net: INetData): void {
let gTime: string = '?_=' + GTime.getTimestamp();
let realUrl: string = net.uri;
if (realUrl.indexOf('?') != -1) {
gTime = '&_=' + GTime.getTimestamp();
}
//url加参数等特殊需求(例如再玩一次需要在dostart接口的url上加埋点)
if (net.addUrl) {
realUrl += net.addUrl;
}
window['$'].ajax({
type: net.type,
// url: realUrl + gTime,
url: realUrl,
cache: false,
dataType: net.dataType,
data: net.param,
async: true,
// success: (result) => {
// this.onResponse(net, result);
// },
// error: (message) => {
// this.onError(net);
// }
});
}
\ No newline at end of file
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