Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xiaoxiaole
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
wildfirecode13
xiaoxiaole
Commits
af18de97
Commit
af18de97
authored
Oct 25, 2019
by
邱旭
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
9a127ddd
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
275 additions
and
2 deletions
+275
-2
MainBase.ts
egret/libs/new_wx/MainBase.ts
+2
-0
TurntablePanelSkin.exml
egret/resource/skins/TurntablePanelSkin.exml
+1
-1
Utils.ts
egret/src/Utils.ts
+70
-0
MapScene.ts
egret/src/mapScene/MapScene.ts
+1
-1
RotaryData.ts
egret/src/panels/TurntablePanel/RotaryData.ts
+12
-0
TurntablePanel.ts
egret/src/panels/TurntablePanel/TurntablePanel.ts
+189
-0
No files found.
egret/libs/new_wx/MainBase.ts
View file @
af18de97
...
...
@@ -54,6 +54,7 @@ import InviteCutTimePanel from "../../src/panels/InviteCutTimePanel";
import
RulePanel2
from
"./components/RulePanel2"
;
import
ScratchPanel
from
"../../src/panels/ScratchPanel"
;
import
ScratchPrizePanel
from
"../../src/panels/ScratchPrizePanel"
;
import
TurntablePanel
from
"../../src/panels/TurntablePanel/TurntablePanel"
;
export
default
class
MainBase
extends
eui
.
UILayer
{
constructor
()
{
...
...
@@ -98,6 +99,7 @@ export default class MainBase extends eui.UILayer {
[
'inviteRule'
,
{
cls
:
InviteRulePanel
}],
[
'scratch'
,
{
cls
:
ScratchPanel
}],
[
'scratchPrize'
,
{
cls
:
ScratchPrizePanel
}],
[
'turnTable'
,
{
cls
:
TurntablePanel
}],
[
'friend'
,
{
cls
:
FriendPanel
}],
[
'ad'
,
{
cls
:
ADPanel
}],
];
...
...
egret/resource/skins/TurntablePanelSkin.exml
View file @
af18de97
...
...
@@ -45,7 +45,7 @@
<e:Button
id=
"start_btn"
label=
""
anchorOffsetX=
"93"
anchorOffsetY=
"140"
horizontalCenter=
"0"
verticalCenter=
"-25"
>
</e:Button>
</e:Group>
<e:Button
id=
"closeBtn"
label=
""
y=
"
295.91"
x=
"611
"
>
<e:Button
id=
"closeBtn"
label=
""
y=
"
135.31"
x=
"565.89
"
>
<e:skinName>
<e:Skin
states=
"up,down,disabled"
>
<e:Image
width=
"100%"
height=
"100%"
source=
"closeCommonBtn_png"
source.down=
"closeCommonBtn_png"
source.disabled=
"closeCommonBtn_png"
/>
...
...
egret/src/Utils.ts
View file @
af18de97
...
...
@@ -52,4 +52,74 @@ export default class Utils {
public
static
prefixInteger
(
num
,
length
)
{
return
(
Array
(
length
).
join
(
'0'
)
+
num
).
slice
(
-
length
);
}
/**
* 对象/数组 深拷贝
* @param {Object} src - 来源对象
* @param {Object} dst - 目标对象
* @returns {Object} obj - 拷贝完成的对象
*/
public
static
deepClone
(
src
,
dst
=
undefined
)
{
let
_obj
=
dst
||
(
src
instanceof
Array
?
[]
:
{});
for
(
let
key
in
src
)
{
let
prop
=
src
[
key
];
if
(
prop
===
_obj
)
{
// 避免相互引用对象导致死循环,如src.a = dst的情况
continue
;
}
_obj
[
key
]
=
((
typeof
prop
===
'object'
)
?
this
.
deepClone
(
prop
)
:
_obj
[
key
]
=
prop
);
// if (typeof prop === 'object') { // 如果这是个对象则递归调用
// _obj[key] = _deepClone(prop);
// } else {
// _obj[key] = prop;
// }
}
return
_obj
;
};
/**
* 产生一个固定范围的随机数(左闭右开)
* @param start
* @param end
*/
public
static
Random
(
start
:
number
,
end
:
number
)
{
return
Math
.
random
()
*
(
end
-
start
)
+
start
;
}
/**
* 产生一个固定范围的随机整数(左闭右开)
* @param start
* @param end
*/
public
static
RandomInt
(
start
:
number
,
end
:
number
)
{
return
Math
.
floor
(
Math
.
random
()
*
(
end
-
start
)
+
start
);
}
/**
* obj是否在array中
* @param obj
* @param array
*/
public
static
isInArray
(
obj
:
any
,
array
:
any
[])
{
for
(
let
i
in
array
)
{
if
(
obj
==
array
[
i
])
{
return
true
;
}
}
return
false
;
}
/**
* 简单的碰撞检测
* @param obj1
* @param obj2
*/
public
static
hitTest
(
obj1
:
any
,
obj2
:
any
):
boolean
{
let
rect1
:
egret
.
Rectangle
=
obj1
.
getBounds
();
let
rect2
:
egret
.
Rectangle
=
obj2
.
getBounds
();
rect1
.
x
=
obj1
.
x
;
rect1
.
y
=
obj1
.
y
;
rect2
.
x
=
obj2
.
x
;
rect2
.
y
=
obj2
.
y
;
return
rect1
.
intersects
(
rect2
);
}
}
\ No newline at end of file
egret/src/mapScene/MapScene.ts
View file @
af18de97
...
...
@@ -646,7 +646,7 @@ export default class MapScene extends Scene {
////////////////////////////////////////////////// 大转盘 //////////////////////////////////////////////////
onTap_turnTableBtn
()
{
console
.
log
(
"onTapTurnTable"
);
PanelCtrl
.
instance
.
show
(
'turnTable'
)
}
protected
initEvents
()
{
...
...
egret/src/panels/TurntablePanel/RotaryData.ts
0 → 100644
View file @
af18de97
let
RotaryData
=
{
key
:
[
],
data
:
{
}
};
export
default
RotaryData
;
egret/src/panels/TurntablePanel/TurntablePanel.ts
0 → 100644
View file @
af18de97
import
{
GDispatcher
}
from
"../../../libs/tc/util/GDispatcher"
;
import
{
DataManager
}
from
"../../../libs/tw/manager/DataManager"
;
import
RotaryData
from
'./RotaryData'
;
import
Panel
from
"../../../libs/new_wx/components/Panel"
;
import
PanelCtrl
from
"../../../libs/new_wx/ctrls/panelCtrl"
;
import
{
ModuleTypes
}
from
"../../../libs/new_wx/types/sceneTypes"
;
import
hdGameDoDojoin
from
"../../../libs/new_tw/ctrls/hdGameDoDojoin"
;
import
submit
from
"../../../libs/new_tw/ctrls/submit"
;
import
Loading
from
"../../../libs/new_wx/components/Loading"
;
import
{
NetManager
}
from
"../../../libs/tw/manager/NetManager"
;
import
Utils
from
"../../Utils"
;
export
default
class
TurntablePanel
extends
Panel
{
public
panel
:
eui
.
Group
;
public
start_btn
:
eui
.
Button
;
public
closeBtn
:
eui
.
Button
;
public
get
skinKey
()
{
return
'TurntablePanel'
}
constructor
(
data
?)
{
super
();
this
.
data
=
data
;
}
start
(
data
?)
{
super
.
start
();
}
initEvents
()
{
super
.
initEvents
();
this
[
"closeBtn"
].
addEventListener
(
egret
.
TouchEvent
.
TOUCH_TAP
,
this
.
onTouchTap_closeBtn
,
this
);
this
.
start_btn
.
addEventListener
(
egret
.
TouchEvent
.
TOUCH_TAP
,
this
.
onTapStart
,
this
);
GDispatcher
.
addEvent
(
'queryPrize'
,
this
.
queryPrize
,
this
);
GDispatcher
.
addEvent
(
'panelEffect'
,
this
.
panelEffect
,
this
);
}
onTouchTap_closeBtn
()
{
console
.
log
(
1111
);
super
.
onTouchTap_closeBtn
();
}
removeEvents
()
{
super
.
removeEvents
();
this
[
"closeBtn"
].
removeEventListener
(
egret
.
TouchEvent
.
TOUCH_TAP
,
this
.
onTouchTap_closeBtn
,
this
);
this
.
start_btn
.
removeEventListener
(
egret
.
TouchEvent
.
TOUCH_TAP
,
this
.
onTapStart
,
this
);
GDispatcher
.
removeEvent
(
'queryPrize'
,
this
.
queryPrize
,
this
);
GDispatcher
.
removeEvent
(
'panelEffect'
,
this
.
panelEffect
,
this
);
}
onTapStart
()
{
this
.
setBtnTouch
(
false
);
// 锁定按钮
Loading
.
instace
.
show
();
GDispatcher
.
dispatchEvent
(
'queryPrize'
);
}
// 设置全部按钮是否可以点击
private
setBtnTouch
(
touchEnabled
:
boolean
)
{
this
.
start_btn
.
touchEnabled
=
touchEnabled
;
}
/**
* 开始抽奖
*/
private
queryPrize
()
{
egret
.
Tween
.
removeTweens
(
this
.
panel
);
this
.
doJoin
();
}
/**
* 开始游戏
*/
private
doJoin
()
{
/////////////////////////////////////////// 开始转盘并查询奖品 ///////////////////////////////////////////
// hdGameDoDojoin((success, res) => {
//
// if(!success) {
// Loading.instace.hide();
// this.setBtnTouch(true);
// return;
// }
// submit((success, res) => {
// Loading.instace.hide();
// if(!success) {
// this.setBtnTouch(true);
// return;
// }
// // if(!res.lottery || res.lottery.type == 'thanks') {
// // PanelCtrl.instance.show(ModuleTypes.GAME_FAIL_NO_PRIZE_PANEL);
// // } else {
// // PanelCtrl.instance.show(ModuleTypes.GAME_FAIL_PRIZE_PANEL, res.lottery);
// // }
// this.rotateByPrize(res.lotteryId, () => {
// if(!res.lottery || res.lottery.type == 'thanks') { // 如果未中奖
// PanelCtrl.instance.show(ModuleTypes.NO_PRIZE_PANEL);
// this.setBtnTouch(true); // 开启按钮
// } else {
// PanelCtrl.instance.show(ModuleTypes.PRIZE_PANEL, res.lottery);
// GDispatcher.dispatchEvent('getCount'); // 更新免费抽奖次数
// this.setBtnTouch(true); // 开启按钮
// }
// });
// }, 2);
// });
}
/**
* 根据奖项转转盘
* @param prizeId
* @param callFun - 缓动回调
*/
private
rotateByPrize
(
prizeId
,
callFun
:
Function
)
{
egret
.
Tween
.
removeTweens
(
this
.
panel
);
// let key = RotaryData.key[prizeId]; // 转盘数据的key
let
index
=
~~
(
Math
.
random
()
*
RotaryData
.
data
[
prizeId
].
length
);
let
rs
=
RotaryData
.
data
[
prizeId
][
index
];
// 奖品在转盘上的范围
let
r
=
Utils
.
Random
(
rs
.
start
,
rs
.
end
)
+
Utils
.
RandomInt
(
9
,
15
)
*
360
;
let
t
=
Utils
.
Random
(
5000
,
8000
);
this
.
rotate
(
r
,
t
,
callFun
);
}
/**
* 开始一次旋转
* @param rotation - 角度
* @param time - 时间
* @param callFun - 缓动回调
*/
private
rotate
(
rotation
:
number
,
time
:
number
,
callFun
:
Function
)
{
let
tw
=
egret
.
Tween
.
get
(
this
.
panel
);
tw
.
to
({
rotation
:
rotation
},
time
,
egret
.
Ease
.
cubicInOut
).
wait
(
500
).
call
(
callFun
);
}
protected
onSkinComplete
():
void
{
super
.
onSkinComplete
();
this
.
onLoad
();
}
protected
onLoad
():
void
{
this
.
initUI
();
}
private
initUI
():
void
{
this
.
getPrizeInfo
();
// 查询奖品
this
.
initEffect
();
}
private
initEffect
()
{
this
.
panelEffect
();
}
private
panelEffect
()
{
egret
.
Tween
.
get
(
this
.
panel
).
to
({
rotation
:
360
},
20000
).
call
(()
=>
{
this
.
panelEffect
();
});
}
protected
async
preLoadRes
()
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
resolve
();
});
}
/**
* 获得所有奖品信息
*/
private
getPrizeInfo
()
{
/////////////////////////////////////////// 查询奖品加入转盘数据 ///////////////////////////////////////////
// let data = DataManager.ins.ajaxElementData.options;
// let options = Utils.deepClone(data);
// for(let i = 0; i < options.length; i++) {
// let v = options[i];
// if(v.scoreArea == "1,1") {
// options.splice(i--, 1);
// }
// }
// for(let i = 0; i < options.length; i++) {
// let v = options[i];
// RotaryData.key.push(v.id);
// RotaryData.data[v.id] = [{start: i * 40 - 15, end: i * 40 + 15}];
// this[`img${i}`].source = v.logo;
// this[`lab${i}`].text = v.name;
// }
console
.
log
(
RotaryData
);
}
}
\ No newline at end of file
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