Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
game-stydy
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
谌继荃
game-stydy
Commits
26bf25a0
Commit
26bf25a0
authored
Dec 02, 2021
by
谌继荃
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
游戏道具(全屏炸弹)
parent
91210898
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
26 deletions
+24
-26
MovableManager.ts
src/lib/MovableManager.ts
+12
-20
addGame.ts
src/planewar/addGame.ts
+5
-0
Boom.ts
src/tools/Boom.ts
+6
-5
Score.ts
src/tools/Score.ts
+1
-1
No files found.
src/lib/MovableManager.ts
View file @
26bf25a0
...
@@ -42,7 +42,6 @@ export default class MovableManager extends FYGE.EventDispatcher {
...
@@ -42,7 +42,6 @@ export default class MovableManager extends FYGE.EventDispatcher {
this
.
checkHitEnemy
();
this
.
checkHitEnemy
();
this
.
checkHitByBullet
();
this
.
checkHitByBullet
();
this
.
checkHitByEnemy
();
this
.
checkHitByEnemy
();
// window.addEventListener("Boom", this.checkAll);
// console.log('移动对象的数量:', this._movableList.length)
// console.log('移动对象的数量:', this._movableList.length)
};
};
...
@@ -68,7 +67,7 @@ export default class MovableManager extends FYGE.EventDispatcher {
...
@@ -68,7 +67,7 @@ export default class MovableManager extends FYGE.EventDispatcher {
private
addScore
()
{
private
addScore
()
{
this
.
Score
+=
10
;
this
.
Score
+=
10
;
console
.
log
(
"this.Score"
,
this
.
Score
);
//
console.log("this.Score", this.Score);
scoreClass
.
change
(
this
.
Score
);
scoreClass
.
change
(
this
.
Score
);
}
}
...
@@ -90,11 +89,11 @@ export default class MovableManager extends FYGE.EventDispatcher {
...
@@ -90,11 +89,11 @@ export default class MovableManager extends FYGE.EventDispatcher {
// console.log("x", x);
// console.log("x", x);
// console.log("y", y);
// console.log("y", y);
if
(
x
<
0
)
{
if
(
x
<
0
)
{
console
.
log
(
"x < 0"
);
//
console.log("x < 0");
this
.
hero
.
x
=
0
;
this
.
hero
.
x
=
0
;
}
else
if
(
x
>
wW
-
dx
)
{
}
else
if
(
x
>
wW
-
dx
)
{
console
.
log
(
"x > wW"
);
//
console.log("x > wW");
this
.
hero
.
x
=
wW
-
dx
;
this
.
hero
.
x
=
wW
-
dx
;
}
}
...
@@ -106,7 +105,7 @@ export default class MovableManager extends FYGE.EventDispatcher {
...
@@ -106,7 +105,7 @@ export default class MovableManager extends FYGE.EventDispatcher {
}
}
/**
/**
* 鼠标点到的差值
移动要减去这个差值,不然会瞬间偏移
* 鼠标点到的差值
* @type {{x: number, y: number}}
* @type {{x: number, y: number}}
*/
*/
mouseDP
=
{
x
:
0
,
y
:
0
};
mouseDP
=
{
x
:
0
,
y
:
0
};
...
@@ -120,22 +119,20 @@ export default class MovableManager extends FYGE.EventDispatcher {
...
@@ -120,22 +119,20 @@ export default class MovableManager extends FYGE.EventDispatcher {
case
FYGE
.
MouseEvent
.
MOUSE_DOWN
:
case
FYGE
.
MouseEvent
.
MOUSE_DOWN
:
this
.
mouseDP
.
x
=
e
.
localX
-
this
.
hero
.
x
;
this
.
mouseDP
.
x
=
e
.
localX
-
this
.
hero
.
x
;
this
.
mouseDP
.
y
=
e
.
localY
-
this
.
hero
.
y
;
this
.
mouseDP
.
y
=
e
.
localY
-
this
.
hero
.
y
;
console
.
log
(
"MOUSE_DOWN"
);
//
console.log("MOUSE_DOWN");
console
.
log
(
"mouseDP"
,
this
.
mouseDP
);
//
console.log("mouseDP", this.mouseDP);
break
;
break
;
case
FYGE
.
MouseEvent
.
MOUSE_UP
:
case
FYGE
.
MouseEvent
.
MOUSE_UP
:
console
.
log
(
"MOUSE_UP"
);
//
console.log("MOUSE_UP");
case
FYGE
.
MouseEvent
.
MOUSE_MOVE
:
case
FYGE
.
MouseEvent
.
MOUSE_MOVE
:
console
.
log
(
"MOUSE_MOVE"
);
//
console.log("MOUSE_MOVE");
const
px
=
e
.
localX
-
this
.
mouseDP
.
x
;
const
px
=
e
.
localX
-
this
.
mouseDP
.
x
;
const
py
=
e
.
localY
-
this
.
mouseDP
.
y
;
const
py
=
e
.
localY
-
this
.
mouseDP
.
y
;
console
.
log
(
"px"
,
px
);
// console.log("px", px);
console
.
log
(
"py"
,
py
);
// console.log("py", py);
// this.hero.position.set(px, py);
this
.
judgeEdge
();
this
.
judgeEdge
();
break
;
break
;
}
}
...
@@ -175,10 +172,9 @@ export default class MovableManager extends FYGE.EventDispatcher {
...
@@ -175,10 +172,9 @@ export default class MovableManager extends FYGE.EventDispatcher {
}
}
checkAll
()
{
checkAll
()
{
console
.
log
(
" this._movableList"
,
this
.
_movableList
);
const
enemyAllList
=
this
.
_movableList
.
filter
((
i
)
=>
i
instanceof
Enemy
);
const
enemyAllList
=
this
.
_movableList
.
filter
((
i
)
=>
i
instanceof
Enemy
);
enemyAllList
.
forEach
((
item
)
=>
{
enemyAllList
.
forEach
((
enemy
)
=>
{
this
.
remove
(
item
);
this
.
remove
(
enemy
);
console
.
log
(
"全屏爆炸"
);
console
.
log
(
"全屏爆炸"
);
});
});
}
}
...
@@ -231,10 +227,6 @@ export default class MovableManager extends FYGE.EventDispatcher {
...
@@ -231,10 +227,6 @@ export default class MovableManager extends FYGE.EventDispatcher {
return
;
return
;
}
}
}
}
// setTimeout(() => {
// this.checkAll();
// }, 3000);
}
}
private
step
()
{
private
step
()
{
...
...
src/planewar/addGame.ts
View file @
26bf25a0
...
@@ -34,9 +34,14 @@ export function addGame(stage: FYGE.Stage) {
...
@@ -34,9 +34,14 @@ export function addGame(stage: FYGE.Stage) {
this
.
pause
=
true
;
this
.
pause
=
true
;
dragDropManager
.
remove
(
hero
);
dragDropManager
.
remove
(
hero
);
pause
.
destroy
(
stage
);
pause
.
destroy
(
stage
);
boom
.
destroy
(
stage
);
enemyFactory
.
destroy
();
enemyFactory
.
destroy
();
movableManager
.
destroy
();
movableManager
.
destroy
();
}
}
function
boomAll
()
{
movableManager
.
checkAll
();
}
movableManager
.
addEventListener
(
"gameover"
,
onGamOver
);
movableManager
.
addEventListener
(
"gameover"
,
onGamOver
);
stage
.
addEventListener
(
"Boom"
,
boomAll
);
}
}
src/tools/Boom.ts
View file @
26bf25a0
let
BoomText
;
let
BoomText
;
export
default
class
Boom
{
export
default
class
Boom
{
private
_stage
:
FYGE
.
Stage
;
constructor
(
stage
:
FYGE
.
Stage
)
{
constructor
(
stage
:
FYGE
.
Stage
)
{
this
.
_stage
=
stage
;
BoomText
=
new
FYGE
.
TextField
();
BoomText
=
new
FYGE
.
TextField
();
BoomText
.
text
=
"
爆炸
"
;
BoomText
.
text
=
"
全屏炸弹
"
;
BoomText
.
fillColor
=
"#000000"
;
BoomText
.
fillColor
=
"#000000"
;
BoomText
.
size
=
50
;
BoomText
.
size
=
50
;
BoomText
.
x
=
5
0
;
BoomText
.
x
=
2
0
;
BoomText
.
y
=
130
;
BoomText
.
y
=
130
;
stage
.
addChildAt
(
BoomText
,
stage
.
children
.
length
-
1
);
stage
.
addChildAt
(
BoomText
,
stage
.
children
.
length
-
1
);
...
@@ -15,8 +17,7 @@ export default class Boom {
...
@@ -15,8 +17,7 @@ export default class Boom {
Boom
()
{
Boom
()
{
console
.
log
(
"爆炸"
);
console
.
log
(
"爆炸"
);
// 目前点击一次不能点击了
this
.
_stage
.
dispatchEvent
(
"Boom"
);
window
.
dispatchEvent
(
new
Event
(
"Boom"
));
}
}
reset
()
{}
reset
()
{}
...
...
src/tools/Score.ts
View file @
26bf25a0
...
@@ -14,7 +14,7 @@ export default class Score {
...
@@ -14,7 +14,7 @@ export default class Score {
change
(
changeScore
)
{
change
(
changeScore
)
{
score
=
changeScore
;
score
=
changeScore
;
scoreText
.
text
=
`当前分数:
${
score
}
`
;
scoreText
.
text
=
`当前分数:
${
score
}
`
;
console
.
log
(
"change---scoreText.text"
,
scoreText
.
text
);
//
console.log("change---scoreText.text", scoreText.text);
}
}
reset
()
{}
reset
()
{}
...
...
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