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
ff302404
Commit
ff302404
authored
Nov 22, 2021
by
wildfirecode13
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
8058a6ae
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
1 deletion
+47
-1
Movable.ts
src/lib/Movable.ts
+3
-0
MovableManager.ts
src/lib/MovableManager.ts
+2
-1
Background.ts
src/planewar/Background.ts
+37
-0
addGame.ts
src/planewar/addGame.ts
+5
-0
No files found.
src/lib/Movable.ts
View file @
ff302404
import
Vector2
from
"./Vector2"
;
export
default
class
Movable
extends
FYGE
.
Sprite
{
getCanRemove
()
{
return
true
;
}
private
_velocity
:
Vector2
;
set
velocity
(
val
:
Vector2
)
{
this
.
_velocity
=
val
}
...
...
src/lib/MovableManager.ts
View file @
ff302404
...
...
@@ -78,7 +78,8 @@ export default class MovableManager extends FYGE.EventDispatcher {
return
x0
<
x1
&&
y0
<
y1
;
}
private
calcCanRemove
(
item
:
FYGE
.
DisplayObject
)
{
private
calcCanRemove
(
item
:
Movable
)
{
if
(
!
item
.
getCanRemove
())
return
;
if
(
item
.
y
>
1624
)
return
true
;
if
(
item
.
y
<
-
item
.
height
)
return
true
;
if
(
item
.
x
>
750
)
return
true
;
...
...
src/planewar/Background.ts
0 → 100644
View file @
ff302404
import
Movable
from
"../lib/Movable"
;
import
MovableManager
from
"../lib/MovableManager"
;
import
Vector2
from
"../lib/Vector2"
;
class
BackgroundItem
extends
Movable
{
constructor
()
{
super
();
this
.
texture
=
FYGE
.
Texture
.
fromUrl
(
'//yun.duiba.com.cn/aurora/assets/bd7b3b10169265123e52d02acf8739db5ff59b3d.png'
);
this
.
velocity
=
new
Vector2
(
0
,
10
)
}
getCanRemove
()
{
return
false
}
}
const
height
=
1624
;
export
default
class
Background
{
constructor
(
stage
:
FYGE
.
Stage
,
movableManager
:
MovableManager
)
{
var
bg
=
new
BackgroundItem
();
var
bg2
=
new
BackgroundItem
();
movableManager
.
add
(
bg
);
movableManager
.
add
(
bg2
);
stage
.
addChild
(
bg
);
stage
.
addChild
(
bg2
);
bg
.
x
=
0
;
bg2
.
y
=
height
;
stage
.
addEventListener
(
FYGE
.
Event
.
ENTER_FRAME
,
()
=>
{
if
(
bg
.
y
>
height
)
{
bg
.
y
=
bg2
.
y
-
height
;
}
if
(
bg2
.
y
>
height
)
{
bg2
.
y
=
bg
.
y
-
height
;
}
});
}
}
\ No newline at end of file
src/planewar/addGame.ts
View file @
ff302404
import
DragDropManager
from
"../dragdrop/DragDropManager"
;
import
MovableManager
from
"../lib/MovableManager"
;
import
Background
from
"./Background"
;
import
EnemyFactory
from
"./EnemyFactory"
;
import
Hero
from
"./Hero"
;
...
...
@@ -8,6 +9,8 @@ export function addGame(stage: FYGE.Stage) {
const
movableManager
=
new
MovableManager
(
stage
);
//创建管理器
const
dragDropManager
=
new
DragDropManager
();
const
background
=
new
Background
(
stage
,
movableManager
);
const
hero
=
stage
.
addChild
(
new
Hero
(
movableManager
));
hero
.
position
.
set
(
300
,
1000
);
...
...
@@ -22,4 +25,6 @@ export function addGame(stage: FYGE.Stage) {
dragDropManager
.
remove
(
hero
);
}
movableManager
.
addEventListener
(
'gameover'
,
onGamOver
);
}
\ 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