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
6a30f9f6
Commit
6a30f9f6
authored
Nov 28, 2021
by
谌继荃
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gameOver
parent
ff302404
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
43 deletions
+46
-43
Background.ts
src/planewar/Background.ts
+31
-26
addGame.ts
src/planewar/addGame.ts
+15
-17
No files found.
src/planewar/Background.ts
View file @
6a30f9f6
...
@@ -4,14 +4,17 @@ import Vector2 from "../lib/Vector2";
...
@@ -4,14 +4,17 @@ import Vector2 from "../lib/Vector2";
class
BackgroundItem
extends
Movable
{
class
BackgroundItem
extends
Movable
{
constructor
()
{
constructor
()
{
super
();
super
();
this
.
texture
=
FYGE
.
Texture
.
fromUrl
(
'//yun.duiba.com.cn/aurora/assets/bd7b3b10169265123e52d02acf8739db5ff59b3d.png'
);
this
.
texture
=
FYGE
.
Texture
.
fromUrl
(
this
.
velocity
=
new
Vector2
(
0
,
10
)
"//yun.duiba.com.cn/aurora/assets/bd7b3b10169265123e52d02acf8739db5ff59b3d.png"
);
this
.
velocity
=
new
Vector2
(
0
,
10
);
}
getCanRemove
()
{
return
false
;
}
}
getCanRemove
()
{
return
false
}
}
}
const
height
=
1624
;
const
height
=
1624
;
export
default
class
Background
{
export
default
class
Background
{
constructor
(
stage
:
FYGE
.
Stage
,
movableManager
:
MovableManager
)
{
constructor
(
stage
:
FYGE
.
Stage
,
movableManager
:
MovableManager
)
{
var
bg
=
new
BackgroundItem
();
var
bg
=
new
BackgroundItem
();
var
bg2
=
new
BackgroundItem
();
var
bg2
=
new
BackgroundItem
();
...
@@ -26,6 +29,8 @@ export default class Background {
...
@@ -26,6 +29,8 @@ export default class Background {
bg2
.
y
=
height
;
bg2
.
y
=
height
;
stage
.
addEventListener
(
FYGE
.
Event
.
ENTER_FRAME
,
()
=>
{
stage
.
addEventListener
(
FYGE
.
Event
.
ENTER_FRAME
,
()
=>
{
console
.
log
(
"bg.y"
,
bg
.
y
);
console
.
log
(
"bg2.y"
,
bg2
.
y
);
if
(
bg
.
y
>
height
)
{
if
(
bg
.
y
>
height
)
{
bg
.
y
=
bg2
.
y
-
height
;
bg
.
y
=
bg2
.
y
-
height
;
}
}
...
...
src/planewar/addGame.ts
View file @
6a30f9f6
...
@@ -4,9 +4,8 @@ import Background from "./Background";
...
@@ -4,9 +4,8 @@ import Background from "./Background";
import
EnemyFactory
from
"./EnemyFactory"
;
import
EnemyFactory
from
"./EnemyFactory"
;
import
Hero
from
"./Hero"
;
import
Hero
from
"./Hero"
;
export
function
addGame
(
stage
:
FYGE
.
Stage
)
{
export
function
addGame
(
stage
:
FYGE
.
Stage
)
{
const
movableManager
=
new
MovableManager
(
stage
);
//创建管理器
const
movableManager
=
new
MovableManager
(
stage
);
//创建管理器
const
dragDropManager
=
new
DragDropManager
();
const
dragDropManager
=
new
DragDropManager
();
const
background
=
new
Background
(
stage
,
movableManager
);
const
background
=
new
Background
(
stage
,
movableManager
);
...
@@ -14,7 +13,6 @@ export function addGame(stage: FYGE.Stage) {
...
@@ -14,7 +13,6 @@ export function addGame(stage: FYGE.Stage) {
const
hero
=
stage
.
addChild
(
new
Hero
(
movableManager
));
const
hero
=
stage
.
addChild
(
new
Hero
(
movableManager
));
hero
.
position
.
set
(
300
,
1000
);
hero
.
position
.
set
(
300
,
1000
);
const
enemyFactory
=
new
EnemyFactory
(
stage
,
movableManager
);
const
enemyFactory
=
new
EnemyFactory
(
stage
,
movableManager
);
dragDropManager
.
add
(
hero
);
dragDropManager
.
add
(
hero
);
...
@@ -22,9 +20,9 @@ export function addGame(stage: FYGE.Stage) {
...
@@ -22,9 +20,9 @@ export function addGame(stage: FYGE.Stage) {
movableManager
.
hero
=
hero
;
movableManager
.
hero
=
hero
;
function
onGamOver
()
{
function
onGamOver
()
{
alert
(
"gameOver"
);
dragDropManager
.
remove
(
hero
);
dragDropManager
.
remove
(
hero
);
enemyFactory
.
destroy
();
}
}
movableManager
.
addEventListener
(
'gameover'
,
onGamOver
);
movableManager
.
addEventListener
(
"gameover"
,
onGamOver
);
}
}
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