Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
db-game-template
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
崔立强
db-game-template
Commits
4b572aa1
Commit
4b572aa1
authored
Dec 06, 2018
by
wildfirecode
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
0d850980
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
133 additions
and
79 deletions
+133
-79
index.html
egret/index.html
+1
-1
getit.png
egret/resource/assets/startScene/getit.png
+0
-0
垃圾桶.png
egret/resource/assets/startScene/垃圾桶.png
+0
-0
default.res.json
egret/resource/default.res.json
+11
-1
StartSkin.exml
egret/resource/skins/StartSkin.exml
+18
-8
StartScene.ts
egret/src/startScene/StartScene.ts
+36
-43
check.ts
egret/src/startScene/check.ts
+14
-12
check2.ts
egret/src/startScene/check2.ts
+23
-0
createBox.ts
egret/src/startScene/createBox.ts
+2
-2
createItems.ts
egret/src/startScene/createItems.ts
+27
-12
vibrate.ts
egret/src/startScene/vibrate.ts
+1
-0
No files found.
egret/index.html
View file @
4b572aa1
...
@@ -78,7 +78,7 @@
...
@@ -78,7 +78,7 @@
</script>
</script>
<script
src=
"output.js"
></script>
<script
src=
"output.js"
></script>
<
div
id=
"debugCanvas"
style=
"position:absolute;opacity: .9;pointer-events: none"
></div
>
<
!-- <div id="debugCanvas" style="position:absolute;opacity: .9;pointer-events: none"></div> --
>
</body>
</body>
</html>
</html>
\ No newline at end of file
egret/resource/assets/startScene/getit.png
0 → 100644
View file @
4b572aa1
3.18 KB
egret/resource/assets/startScene/垃圾桶.png
0 → 100644
View file @
4b572aa1
12.8 KB
egret/resource/default.res.json
View file @
4b572aa1
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
},
},
{
{
"name"
:
"preload"
,
"name"
:
"preload"
,
"keys"
:
"dot_png"
"keys"
:
"dot_png
,垃圾桶_png,getit_png
"
}
}
],
],
"resources"
:
[
"resources"
:
[
...
@@ -261,6 +261,16 @@
...
@@ -261,6 +261,16 @@
"name"
:
"dot_png"
,
"name"
:
"dot_png"
,
"type"
:
"image"
,
"type"
:
"image"
,
"url"
:
"assets/startScene/dot.png"
"url"
:
"assets/startScene/dot.png"
},
{
"name"
:
"垃圾桶_png"
,
"type"
:
"image"
,
"url"
:
"assets/startScene/垃圾桶.png"
},
{
"name"
:
"getit_png"
,
"type"
:
"image"
,
"url"
:
"assets/startScene/getit.png"
}
}
]
]
}
}
\ No newline at end of file
egret/resource/skins/StartSkin.exml
View file @
4b572aa1
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
<w:Config
id=
"16705cb4eec"
/>
<w:Config
id=
"16705cb4eec"
/>
<e:Group
id=
"group"
x=
"0"
y=
"0"
>
<e:Group
id=
"group"
x=
"0"
y=
"0"
>
<e:Image
id=
"bg"
source=
"startscenebg_jpg"
x=
"0"
y=
"0"
locked=
"true"
/>
<e:Image
id=
"bg"
source=
"startscenebg_jpg"
x=
"0"
y=
"0"
locked=
"true"
/>
<e:Group
id=
"lights"
x=
"-3.04"
y=
"700.53"
>
<e:Group
id=
"lights"
x=
"-3.04"
y=
"700.53"
locked=
"true"
>
<e:Image
id=
"lights1"
source=
"灯1_png"
y=
"0"
x=
"0"
/>
<e:Image
id=
"lights1"
source=
"灯1_png"
y=
"0"
x=
"0"
/>
<e:Image
id=
"lights2"
source=
"灯2_png"
x=
"0"
y=
"0"
/>
<e:Image
id=
"lights2"
source=
"灯2_png"
x=
"0"
y=
"0"
/>
</e:Group>
</e:Group>
...
@@ -16,26 +16,36 @@
...
@@ -16,26 +16,36 @@
<e:Image
id=
"arrow"
source=
"arrow_png"
y=
"1173"
anchorOffsetX=
"275"
anchorOffsetY=
"279"
rotation=
"0"
horizontalCenter=
"-2"
/>
<e:Image
id=
"arrow"
source=
"arrow_png"
y=
"1173"
anchorOffsetX=
"275"
anchorOffsetY=
"279"
rotation=
"0"
horizontalCenter=
"-2"
/>
<e:Image
id=
"pipeline"
source=
"bg3_png"
y=
"0"
horizontalCenter=
"0"
/>
<e:Image
id=
"pipeline"
source=
"bg3_png"
y=
"0"
horizontalCenter=
"0"
/>
<e:Image
id=
"fg"
source=
"前景_png"
x=
"0"
y=
"1333"
/>
<e:Image
id=
"fg"
source=
"前景_png"
x=
"0"
y=
"1333"
/>
<e:Button
id=
"leftBtn"
label=
""
y=
"1362"
scaleX=
"1"
scaleY=
"1"
left=
"43"
alpha=
"1"
>
<e:Image
id=
"guide"
source=
"dot_png"
x=
"0"
y=
"0"
width=
"750"
height=
"1624"
touchEnabled=
"false"
/>
<e:Label
id=
"exemptionTxt"
text=
"*兑换项与活动均与设备制造商Apple Inc.公司无关*"
width=
"100%"
verticalAlign=
"middle"
textAlign=
"center"
size=
"18"
y=
"1593.67"
x=
"10"
textColor=
"0x000000"
/>
<e:Button
id=
"rightBtn"
label=
""
y=
"1292.31"
scaleX=
"1"
scaleY=
"1"
alpha=
"1"
x=
"550.33"
>
<e:skinName>
<e:skinName>
<e:Skin
states=
"up,down,disabled"
>
<e:Skin
states=
"up,down,disabled"
>
<e:Image
width=
"100%"
height=
"100%"
source=
"btn
Left_png"
source.down=
"btnLeft_png"
source.disabled=
"btnLef
t_png"
/>
<e:Image
width=
"100%"
height=
"100%"
source=
"btn
Right_png"
source.down=
"btnRight_png"
source.disabled=
"btnRigh
t_png"
/>
<e:Label
id=
"labelDisplay"
horizontalCenter=
"0"
verticalCenter=
"0"
size=
"26"
/>
<e:Label
id=
"labelDisplay"
horizontalCenter=
"0"
verticalCenter=
"0"
size=
"26"
/>
</e:Skin>
</e:Skin>
</e:skinName>
</e:skinName>
</e:Button>
</e:Button>
<e:Button
id=
"
rightBtn"
label=
""
y=
"1362"
scaleX=
"1"
scaleY=
"1"
alpha=
"1"
x=
"550.33
"
>
<e:Button
id=
"
leftBtn"
label=
""
y=
"1292.31"
scaleX=
"1"
scaleY=
"1"
left=
"43"
alpha=
"1
"
>
<e:skinName>
<e:skinName>
<e:Skin
states=
"up,down,disabled"
>
<e:Skin
states=
"up,down,disabled"
>
<e:Image
width=
"100%"
height=
"100%"
source=
"btn
Right_png"
source.down=
"btnRight_png"
source.disabled=
"btnRigh
t_png"
/>
<e:Image
width=
"100%"
height=
"100%"
source=
"btn
Left_png"
source.down=
"btnLeft_png"
source.disabled=
"btnLef
t_png"
/>
<e:Label
id=
"labelDisplay"
horizontalCenter=
"0"
verticalCenter=
"0"
size=
"26"
/>
<e:Label
id=
"labelDisplay"
horizontalCenter=
"0"
verticalCenter=
"0"
size=
"26"
/>
</e:Skin>
</e:Skin>
</e:skinName>
</e:skinName>
</e:Button>
</e:Button>
<e:Image
id=
"guide"
source=
"dot_png"
x=
"0"
y=
"0"
width=
"750"
height=
"1624"
visible=
"false"
/>
<e:Image
id=
"guild2pic"
source=
"垃圾桶_png"
x=
"54.01"
y=
"1343.74"
touchEnabled=
"false"
/>
<e:Label
id=
"aa"
text=
"点击左右按钮控制跷跷板的方向"
width=
"100%"
size=
"26"
y=
"1490"
x=
"0"
textColor=
"0xffffff"
verticalAlign=
"middle"
textAlign=
"center"
visible=
"false"
/>
<e:Label
id=
"tips"
text=
"点击左右按钮控制跷跷板的方向"
width=
"100%"
size=
"26"
y=
"1491.7"
x=
"0"
textColor=
"0xffffff"
verticalAlign=
"middle"
textAlign=
"center"
/>
<e:Label
id=
"tips2"
text=
"炸弹放进垃圾桶就安全了哦~"
size=
"26"
y=
"1227.7"
x=
"38"
textColor=
"0xFFFFFF"
verticalAlign=
"middle"
textAlign=
"left"
/>
<e:Button
id=
"getitBtn"
label=
""
x=
"497"
y=
"1200.03"
>
<e:skinName>
<e:Skin
states=
"up,down,disabled"
>
<e:Image
width=
"100%"
height=
"100%"
source=
"getit_png"
source.down=
"getit_png"
source.disabled=
"getit_png"
/>
<e:Label
id=
"labelDisplay"
horizontalCenter=
"0"
verticalCenter=
"0"
/>
</e:Skin>
</e:skinName>
</e:Button>
</e:Group>
</e:Group>
<e:Label
id=
"exemptionTxt0"
text=
"*兑换项与活动均与设备制造商Apple Inc.公司无关*"
width=
"100%"
verticalAlign=
"middle"
textAlign=
"center"
size=
"18"
y=
"1611"
x=
"10"
textColor=
"0x000000"
/>
<e:Button
id=
"recordBtn"
label=
"奖品记录"
y=
"16"
scaleX=
"1"
scaleY=
"1"
right=
"23"
visible=
"false"
>
<e:Button
id=
"recordBtn"
label=
"奖品记录"
y=
"16"
scaleX=
"1"
scaleY=
"1"
right=
"23"
visible=
"false"
>
<e:skinName>
<e:skinName>
<e:Skin
states=
"up,down,disabled"
>
<e:Skin
states=
"up,down,disabled"
>
...
...
egret/src/startScene/StartScene.ts
View file @
4b572aa1
...
@@ -3,31 +3,55 @@ import EgretRender from "../physics/EgretRender";
...
@@ -3,31 +3,55 @@ import EgretRender from "../physics/EgretRender";
import
getAngle
from
"../physics/utils/getAngle"
;
import
getAngle
from
"../physics/utils/getAngle"
;
import
getRotation
from
"../physics/utils/getRotation"
;
import
getRotation
from
"../physics/utils/getRotation"
;
import
check
from
"./check"
;
import
check
from
"./check"
;
import
check2
from
"./check2"
;
import
createBox
from
"./createBox"
;
import
createBox
from
"./createBox"
;
import
createItems
from
"./createItems"
;
import
createItems
from
"./createItems"
;
import
wait
from
"../../libs/new_tc/wait"
;
export
default
class
StartScene
extends
StartSceneBase
{
export
default
class
StartScene
extends
StartSceneBase
{
_engine
:
Matter
.
Engine
;
_engine
:
Matter
.
Engine
;
_egretRender
:
EgretRender
;
_egretRender
:
EgretRender
;
// _debugRender:DebugRender;
private
_lastTimestamp
=
0
;
private
_lastTimestamp
=
0
;
_startStandbyBubblesLeft
:
number
;
_startStandbyBubblesLeft
:
number
;
_startStandbyBubblesRight
:
number
;
_startStandbyBubblesRight
:
number
;
egretRenderContainer
:
egret
.
Sprite
;
egretRenderContainer
:
egret
.
Sprite
;
// arrowContainer: egret.Sprite;
_currentDisplay
:
egret
.
DisplayObject
;
private
removeGuideAndResume
()
{
this
[
'guide'
].
visible
=
this
[
'tips'
].
visible
=
this
[
'tips2'
].
visible
=
this
[
'guild2pic'
].
visible
=
this
[
'getitBtn'
].
visible
=
false
;
this
.
_lastTimestamp
=
0
;
egret
.
ticker
.
resume
();
// 打开渲染与心跳
this
[
'group'
].
addChildAt
(
this
.
egretRenderContainer
,
5
);
}
onCollision
(
body
:
Matter
.
Body
)
{
if
(
localStorage
.
getItem
(
'guilde1'
)
==
'1'
)
return
;
localStorage
.
setItem
(
'guilde1'
,
'1'
);
egret
.
ticker
.
pause
();
// 关闭渲染与心跳
this
[
'guide'
].
visible
=
this
[
'tips'
].
visible
=
true
;
this
[
'group'
].
addChild
(
this
.
egretRenderContainer
);
}
onCollisionBoom
(
body
:
Matter
.
Body
)
{
if
(
localStorage
.
getItem
(
'guilde2'
)
==
'1'
)
return
;
localStorage
.
setItem
(
'guilde2'
,
'1'
);
egret
.
ticker
.
pause
();
// 关闭渲染与心跳
this
[
'guide'
].
visible
=
this
[
'tips2'
].
visible
=
this
[
'guild2pic'
].
visible
=
this
[
'getitBtn'
].
visible
=
true
;
// this['group'].addChild(this.egretRenderContainer);
}
async
start
(
data
?)
{
async
start
(
data
?)
{
super
.
start
();
super
.
start
();
egret
.
lifecycle
.
onPause
=
()
=>
{
egret
.
lifecycle
.
onPause
=
()
=>
{
console
.
log
(
"app 进入后台"
);
console
.
log
(
"app 进入后台"
);
egret
.
ticker
.
pause
();
// 关闭渲染与心跳
egret
.
ticker
.
pause
();
// 关闭渲染与心跳
}
}
egret
.
lifecycle
.
onResume
=
()
=>
{
egret
.
lifecycle
.
onResume
=
()
=>
{
console
.
log
(
"app 进入前台"
);
console
.
log
(
"app 进入前台"
);
this
.
_lastTimestamp
=
0
;
if
(
this
[
'guide'
].
visible
==
false
)
{
egret
.
ticker
.
resume
();
// 打开渲染与心跳
this
.
_lastTimestamp
=
0
;
egret
.
ticker
.
resume
();
// 打开渲染与心跳
}
}
}
//创建引擎
//创建引擎
...
@@ -39,13 +63,10 @@ export default class StartScene extends StartSceneBase {
...
@@ -39,13 +63,10 @@ export default class StartScene extends StartSceneBase {
this
.
_egretRender
=
new
EgretRender
(
this
.
egretRenderContainer
,
this
.
_engine
);
this
.
_egretRender
=
new
EgretRender
(
this
.
egretRenderContainer
,
this
.
_engine
);
this
[
'group'
].
y
=
this
.
stage
.
stageHeight
-
1624
;
this
[
'group'
].
y
=
this
.
stage
.
stageHeight
-
1624
;
this
[
'group'
].
addChildAt
(
this
.
egretRenderContainer
,
5
);
this
[
'group'
].
addChildAt
(
this
.
egretRenderContainer
,
5
);
// [this['basket_bottom'], this['basket_top'], this['glass']].forEach(item =>
// egret.Tween.get(item).set({ alpha: 0 }).to({ alpha: 1 }, 500));
// this.arrowContainer = new egret.Sprite();
// this['group'].addChild(this.arrowContainer);
this
[
'group'
].
addChild
(
this
[
'leftBtn'
]);
this
[
'group'
].
addChild
(
this
[
'leftBtn'
]);
this
[
'group'
].
addChild
(
this
[
'rightBtn'
]);
this
[
'group'
].
addChild
(
this
[
'rightBtn'
]);
this
[
'group'
].
addChild
(
this
[
'guild2pic'
]);
this
[
'guide'
].
visible
=
this
[
'tips'
].
visible
=
this
[
'tips2'
].
visible
=
this
[
'guild2pic'
].
visible
=
this
[
'getitBtn'
].
visible
=
false
;
// run the engine
// run the engine
this
.
runEngine
();
this
.
runEngine
();
...
@@ -63,9 +84,6 @@ export default class StartScene extends StartSceneBase {
...
@@ -63,9 +84,6 @@ export default class StartScene extends StartSceneBase {
});
});
Matter
.
Render
.
run
(
render
);
Matter
.
Render
.
run
(
render
);
// this._debugRender=new DebugRender(this._engine);
// this['group'].addChild(this._debugRender);
// this.initJoker(this['joker']);
// this.initJoker(this['joker']);
this
.
initLights
(
this
[
'lights1'
],
this
[
'lights2'
]);
this
.
initLights
(
this
[
'lights1'
],
this
[
'lights2'
]);
this
.
runGame
();
this
.
runGame
();
...
@@ -133,46 +151,21 @@ export default class StartScene extends StartSceneBase {
...
@@ -133,46 +151,21 @@ export default class StartScene extends StartSceneBase {
return
false
;
return
false
;
}
}
let
dir
=
1
;
let
currentRotation
=
0
;
let
currentSeesawRotation
;
const
shake
:
any
=
()
=>
{
currentRotation
+=
(
0.1
*
dir
);
if
(
currentRotation
>=
1
)
dir
=
-
1
else
if
(
currentRotation
<=
-
1
)
dir
=
1
// let rotation = currentRotation + currentSeesawRotation;
// if (rotation > rotationLimit) {
// rotation = rotationLimit;
// }
// if (rotation < -rotationLimit) {
// rotation = -rotationLimit;
// }
console
.
log
(
currentRotation
)
Matter
.
Body
.
setAngle
(
seesaw
,
getAngle
(
currentSeesawRotation
+
currentRotation
));
}
currentRotation
=
0
;
currentSeesawRotation
=
getRotation
(
seesaw
.
angle
);
// egret.startTick(shake, this);
[
this
[
'leftBtn'
],
this
[
'rightBtn'
]].
forEach
(
btn
=>
{
[
this
[
'leftBtn'
],
this
[
'rightBtn'
]].
forEach
(
btn
=>
{
btn
.
addEventListener
(
egret
.
TouchEvent
.
TOUCH_BEGIN
,
(
e
:
egret
.
TouchEvent
)
=>
{
btn
.
addEventListener
(
egret
.
TouchEvent
.
TOUCH_BEGIN
,
(
e
:
egret
.
TouchEvent
)
=>
{
touchLeft
=
e
.
stageX
<
375
;
touchLeft
=
e
.
stageX
<
375
;
touchRight
=
!
touchLeft
;
touchRight
=
!
touchLeft
;
ontick
();
ontick
();
egret
.
startTick
(
ontick
,
this
);
egret
.
startTick
(
ontick
,
this
);
// egret.stopTick(shake, this);
if
(
this
[
'guide'
].
visible
)
{
this
.
removeGuideAndResume
();
}
},
this
);
},
this
);
});
});
[
this
[
'leftBtn'
],
this
[
'rightBtn'
]].
forEach
(
btn
=>
{
[
this
[
'leftBtn'
],
this
[
'rightBtn'
]].
forEach
(
btn
=>
{
btn
.
addEventListener
(
egret
.
TouchEvent
.
TOUCH_END
,
(
e
:
egret
.
TouchEvent
)
=>
{
btn
.
addEventListener
(
egret
.
TouchEvent
.
TOUCH_END
,
(
e
:
egret
.
TouchEvent
)
=>
{
egret
.
stopTick
(
ontick
,
this
);
egret
.
stopTick
(
ontick
,
this
);
currentRotation
=
0
;
currentSeesawRotation
=
getRotation
(
seesaw
.
angle
);
// egret.startTick(shake, this);
},
this
);
},
this
);
});
});
}
}
...
@@ -193,8 +186,8 @@ export default class StartScene extends StartSceneBase {
...
@@ -193,8 +186,8 @@ export default class StartScene extends StartSceneBase {
Matter
.
Engine
.
update
(
this
.
_engine
,
delta
);
Matter
.
Engine
.
update
(
this
.
_engine
,
delta
);
this
.
_egretRender
.
run
();
this
.
_egretRender
.
run
();
// this._debugRender.run();
// this._debugRender.run();
// console.log(getRotation(this._seesaw.angle))
check
(
this
);
check
(
this
);
check2
(
this
);
return
false
;
return
false
;
}
}
...
...
egret/src/startScene/check.ts
View file @
4b572aa1
import
{
award
}
from
"./collisionConfig"
;
import
{
award
}
from
"./collisionConfig"
;
import
LabelType
from
"./LabelType"
;
import
StartScene
from
"./StartScene"
;
import
StartScene
from
"./StartScene"
;
import
{
playBoom
,
playSuccess
,
playScoreAni
}
from
"./playMovieClip"
;
import
vibrate
from
"./vibrate"
;
import
vibrate
from
"./vibrate"
;
import
LabelType
from
"./LabelType"
;
const
check
=
(
_this
:
StartScene
)
=>
{
const
check
=
(
_this
:
StartScene
)
=>
{
const
center
=
109
;
const
center
=
109
;
...
@@ -11,8 +10,8 @@ const check = (_this: StartScene) => {
...
@@ -11,8 +10,8 @@ const check = (_this: StartScene) => {
const
h
=
100
;
const
h
=
100
;
const
center2
=
643
;
const
center2
=
643
;
const
paddingX2
=
40
+
5
;
const
paddingX2
=
40
+
5
;
const
ypos2
=
1386
-
20
-
5
;
const
ypos2
=
1386
-
20
-
5
;
const
h2
=
50
;
const
h2
=
50
;
// _this._egretRender._root.graphics.beginFill(0xff0000, 1);
// _this._egretRender._root.graphics.beginFill(0xff0000, 1);
...
@@ -35,6 +34,10 @@ const check = (_this: StartScene) => {
...
@@ -35,6 +34,10 @@ const check = (_this: StartScene) => {
}
}
}
}
const
{
x
,
y
}
=
i
.
position
;
const
{
x
,
y
}
=
i
.
position
;
if
(
y
>
1550
)
{
_this
.
_egretRender
.
remove
(
i
);
return
;
}
const
xResult
=
x
>
(
center
-
paddingX
)
&&
x
<
(
center
+
paddingX
);
const
xResult
=
x
>
(
center
-
paddingX
)
&&
x
<
(
center
+
paddingX
);
const
yResult
=
y
>
ypos
&&
y
<
(
ypos
+
h
);
const
yResult
=
y
>
ypos
&&
y
<
(
ypos
+
h
);
const
xResult2
=
x
>
(
center2
-
paddingX2
)
&&
x
<
(
center2
+
paddingX2
);
const
xResult2
=
x
>
(
center2
-
paddingX2
)
&&
x
<
(
center2
+
paddingX2
);
...
@@ -42,20 +45,19 @@ const check = (_this: StartScene) => {
...
@@ -42,20 +45,19 @@ const check = (_this: StartScene) => {
const
fallingIn
=
xResult
&&
yResult
||
xResult2
&&
yResult2
;
const
fallingIn
=
xResult
&&
yResult
||
xResult2
&&
yResult2
;
if
(
fallingIn
&&
i
.
velocity
.
y
>
0
&&
!
i
[
'timer'
])
{
if
(
fallingIn
&&
i
.
velocity
.
y
>
0
&&
!
i
[
'timer'
])
{
i
[
'timer'
]
=
Date
.
now
();
i
[
'timer'
]
=
Date
.
now
();
console
.
log
(
i
.
label
);
//
console.log(i.label);
if
(
i
.
label
==
LabelType
.
Boom
)
{
if
(
i
.
label
==
LabelType
.
Boom
)
{
_this
.
_egretRender
.
remove
(
i
);
_this
.
_egretRender
.
remove
(
i
);
vibrate
(
_this
,
2
);
if
(
xResult
&&
yResult
){
// playBoom(_this.egretRenderContainer);
// playScoreAni(_this.egretRenderContainer, -1);
}
else
{
vibrate
(
_this
,
2
);
}
}
}
else
{
else
{
console
.
log
(
'不是boom'
,
Date
.
now
()
/
1000
);
//
console.log('不是boom', Date.now() / 1000);
_this
.
_egretRender
.
remove
(
i
);
_this
.
_egretRender
.
remove
(
i
);
// playScoreAni(_this.egretRenderContainer, 1)
// playSuccess(_this.egretRenderContainer);
}
}
// _this.onGetAward();
}
}
})
})
...
...
egret/src/startScene/check2.ts
0 → 100644
View file @
4b572aa1
import
StartScene
from
"./StartScene"
;
import
{
basket
}
from
"./collisionConfig"
;
import
LabelType
from
"./LabelType"
;
export
default
(
that
:
StartScene
)
=>
{
Matter
.
Events
.
on
(
that
.
_engine
,
'collisionEnd'
,
(
event
)
=>
{
const
pairs
=
event
.
pairs
;
for
(
const
pair
of
pairs
)
{
const
{
bodyA
,
bodyB
}
=
pair
;
if
((
bodyA
.
label
!=
LabelType
.
Boom
&&
bodyB
.
collisionFilter
.
group
==
basket
)
||
bodyB
.
label
!=
LabelType
.
Boom
&&
bodyA
.
collisionFilter
.
group
==
basket
)
{
that
.
onCollision
(
bodyA
.
collisionFilter
.
group
==
basket
?
bodyB
:
bodyA
);
break
;
}
if
((
bodyA
.
label
==
LabelType
.
Boom
&&
bodyB
.
collisionFilter
.
group
==
basket
)
||
bodyB
.
label
==
LabelType
.
Boom
&&
bodyA
.
collisionFilter
.
group
==
basket
)
{
that
.
onCollisionBoom
(
bodyA
.
label
==
LabelType
.
Boom
?
bodyA
:
bodyB
);
break
;
}
}
});
}
\ No newline at end of file
egret/src/startScene/createBox.ts
View file @
4b572aa1
...
@@ -3,10 +3,10 @@ import StartScene from "./StartScene";
...
@@ -3,10 +3,10 @@ import StartScene from "./StartScene";
const
createBox
=
(
_this
:
StartScene
)
=>
{
const
createBox
=
(
_this
:
StartScene
)
=>
{
_this
.
_egretRender
.
rectangle
(
750
/
2
,
1624
,
750
,
10
,
null
,
{
isStatic
:
true
,
collisionFilter
:
{
group
:
wall
,
category
:
wall
,
mask
:
wallMask
}
});
_this
.
_egretRender
.
rectangle
(
750
/
2
,
1624
,
750
,
10
,
null
,
{
isStatic
:
true
,
collisionFilter
:
{
group
:
wall
,
category
:
wall
,
mask
:
wallMask
}
});
_this
.
_egretRender
.
rectangle
(
0
,
1624
/
2
,
40
,
1624
,
null
,
{
isStatic
:
true
,
collisionFilter
:
{
group
:
wall
,
category
:
wall
,
mask
:
wallMask
}
});
_this
.
_egretRender
.
rectangle
(
15
,
1624
/
2
,
40
,
1624
,
null
,
{
isStatic
:
true
,
collisionFilter
:
{
group
:
wall
,
category
:
wall
,
mask
:
wallMask
}
});
_this
.
_egretRender
.
rectangle
(
750
,
1624
/
2
,
10
,
1624
,
null
,
{
isStatic
:
true
,
collisionFilter
:
{
group
:
wall
,
category
:
wall
,
mask
:
wallMask
}
});
_this
.
_egretRender
.
rectangle
(
750
,
1624
/
2
,
10
,
1624
,
null
,
{
isStatic
:
true
,
collisionFilter
:
{
group
:
wall
,
category
:
wall
,
mask
:
wallMask
}
});
const
seesaw
=
_this
.
_egretRender
.
rectangle
(
37
3
,
1173
,
503
,
70
,
_this
[
'arrow'
],
{
const
seesaw
=
_this
.
_egretRender
.
rectangle
(
37
5
,
1173
,
503
,
70
,
_this
[
'arrow'
],
{
isStatic
:
true
,
isStatic
:
true
,
restitution
:
0
,
restitution
:
0
,
collisionFilter
:
{
group
:
basket
,
category
:
basket
,
mask
:
basketMask
},
collisionFilter
:
{
group
:
basket
,
category
:
basket
,
mask
:
basketMask
},
...
...
egret/src/startScene/createItems.ts
View file @
4b572aa1
import
getAngle
from
"../physics/utils/getAngle"
;
import
{
award
,
awardMask
}
from
"./collisionConfig"
;
import
{
award
,
awardMask
}
from
"./collisionConfig"
;
import
createItem
from
"./items/createItem"
;
import
createItem
from
"./items/createItem"
;
import
StartScene
from
"./StartScene"
;
import
LabelType
from
"./LabelType"
;
import
LabelType
from
"./LabelType"
;
import
StartScene
from
"./StartScene"
;
const
startY
=
984
;
const
startX
=
100
;
const
restitution
=
0.7
;
// const types = [LabelType.Boom];
const
types
=
[
LabelType
.
Boom
,
LabelType
.
IceCream
,
LabelType
.
Donut
,
LabelType
.
Candy2
,
LabelType
.
Gift2
,
LabelType
.
Gift3
,
LabelType
.
Egg
];
const
frameInterval
=
60
;
export
default
(
_this
:
StartScene
)
=>
{
export
default
(
_this
:
StartScene
)
=>
{
const
startY
=
984
;
let
pastFrame
=
0
;
const
startX
=
100
;
const
ontick
=
()
=>
{
setInterval
(()
=>
{
if
(
pastFrame
<
frameInterval
)
{
const
types
=
[
LabelType
.
Boom
,
LabelType
.
IceCream
,
LabelType
.
Donut
,
LabelType
.
Candy2
,
LabelType
.
Gift2
,
LabelType
.
Gift3
,
LabelType
.
Egg
];
pastFrame
++
;
return
};
if
(
pastFrame
>=
frameInterval
)
pastFrame
=
0
;
const
i
=
Math
.
floor
(
Math
.
random
()
*
types
.
length
);
const
i
=
Math
.
floor
(
Math
.
random
()
*
types
.
length
);
const
restitution
=
0.7
;
const
type
=
types
[
i
];
const
type
=
types
[
i
];
let
body
;
if
(
type
==
LabelType
.
Candy2
)
{
if
(
type
==
LabelType
.
Candy2
)
{
const
forceScale
=
15
;
const
forceScale
=
15
;
const
leftStart
=
{
x
:
startX
,
y
:
startY
,
forceX
:
0.01
*
forceScale
};
const
leftStart
=
{
x
:
startX
,
y
:
startY
,
forceX
:
0.01
*
forceScale
};
...
@@ -18,27 +29,28 @@ export default (_this: StartScene) => {
...
@@ -18,27 +29,28 @@ export default (_this: StartScene) => {
const
start
=
Math
.
random
()
>
0.5
?
leftStart
:
rightStart
;
const
start
=
Math
.
random
()
>
0.5
?
leftStart
:
rightStart
;
const
scale
=
2
;
const
scale
=
2
;
const
baseItem
=
createItem
(
scale
,
type
);
const
baseItem
=
createItem
(
scale
,
type
);
_this
.
_egretRender
.
rectangle
(
start
.
x
,
start
.
y
,
49
*
scale
,
18
*
scale
,
baseItem
,
body
=
_this
.
_egretRender
.
rectangle
(
start
.
x
,
start
.
y
,
49
*
scale
,
18
*
scale
,
baseItem
,
{
{
isStatic
:
false
,
isStatic
:
false
,
force
:
{
x
:
start
.
forceX
,
y
:
0
},
force
:
{
x
:
start
.
forceX
,
y
:
0
},
friction
:
0
,
friction
:
0
,
restitution
:
restitution
,
restitution
:
restitution
,
label
:
type
,
label
:
type
,
angle
:
getAngle
(
10
),
collisionFilter
:
{
group
:
award
,
category
:
award
,
mask
:
awardMask
}
collisionFilter
:
{
group
:
award
,
category
:
award
,
mask
:
awardMask
}
}
}
);
);
}
else
{
}
else
{
const
forceScale
=
7
;
const
forceScale
=
10
;
const
leftStart
=
{
x
:
startX
,
y
:
startY
,
forceX
:
0.01
*
forceScale
};
const
leftStart
=
{
x
:
startX
,
y
:
startY
,
forceX
:
0.01
*
forceScale
};
const
rightStart
=
{
x
:
750
-
startX
,
y
:
startY
,
forceX
:
-
0.01
*
forceScale
};
const
rightStart
=
{
x
:
750
-
startX
,
y
:
startY
,
forceX
:
-
0.01
*
forceScale
};
const
start
=
Math
.
random
()
>
0.5
?
leftStart
:
rightStart
;
const
start
=
Math
.
random
()
>
0.5
?
leftStart
:
rightStart
;
const
size
=
49
*
1.15
;
const
size
=
49
*
1.15
;
const
maxsize
=
49
;
const
maxsize
=
49
;
const
baseItem
=
createItem
(
size
/
maxsize
,
type
);
const
baseItem
=
createItem
(
size
/
maxsize
,
type
);
_this
.
_egretRender
.
circle
(
start
.
x
,
start
.
y
,
size
/
2
,
baseItem
,
body
=
_this
.
_egretRender
.
circle
(
start
.
x
,
start
.
y
,
size
/
2
,
baseItem
,
{
{
label
:
type
,
label
:
type
,
isStatic
:
false
,
isStatic
:
false
,
force
:
{
x
:
start
.
forceX
,
y
:
0
},
force
:
{
x
:
start
.
forceX
,
y
:
0
},
friction
:
0
,
friction
:
0
,
...
@@ -47,5 +59,8 @@ export default (_this: StartScene) => {
...
@@ -47,5 +59,8 @@ export default (_this: StartScene) => {
}
}
);
);
}
}
},
1000
);
return
false
;
}
egret
.
startTick
(
ontick
,
this
)
}
}
\ No newline at end of file
egret/src/startScene/vibrate.ts
View file @
4b572aa1
export
default
(
view
:
egret
.
DisplayObject
,
count
=
2
,
strength
=
10
)
=>
{
export
default
(
view
:
egret
.
DisplayObject
,
count
=
2
,
strength
=
10
)
=>
{
view
.
x
=
view
.
y
=
0
;
return
new
Promise
((
r
)
=>
{
return
new
Promise
((
r
)
=>
{
const
pos
=
[
const
pos
=
[
{
x
:
strength
,
y
:
0
},
{
x
:
strength
,
y
:
0
},
...
...
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