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
3442846d
Commit
3442846d
authored
Nov 19, 2021
by
wildfirecode13
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
cc0f1529
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
35 additions
and
6 deletions
+35
-6
Enemy.ts
src/Enemy.ts
+19
-2
Hero.ts
src/Hero.ts
+3
-0
MovableManager.ts
src/MovableManager.ts
+1
-0
addGame.ts
src/addGame.ts
+8
-2
IWeaponHost.ts
src/weapon/IWeaponHost.ts
+2
-0
Weapon.ts
src/weapon/Weapon.ts
+2
-2
No files found.
src/Enemy.ts
View file @
3442846d
import
Vector2
from
"./lib/Vector2"
;
import
Movable
from
"./Movable"
;
import
MovableManager
from
"./MovableManager"
;
import
{
IWeaponHost
}
from
"./weapon/IWeaponHost"
;
import
Weapon
from
"./weapon/Weapon"
;
export
default
class
Enemy
extends
Movable
{
constructor
()
{
export
default
class
Enemy
extends
Movable
implements
IWeaponHost
{
movableManager
:
MovableManager
;
constructor
(
movableManager
:
MovableManager
)
{
super
();
this
.
movableManager
=
movableManager
;
movableManager
.
add
(
this
);
this
.
texture
=
FYGE
.
Texture
.
fromUrl
(
'//yun.duiba.com.cn/spark/assets/enemy2_fly1.0f4acd3728e90763d98a7328a5a32dbc78ec204e.png'
)
const
weapon
=
new
Weapon
(
this
);
}
getShootVelocity
()
{
return
new
Vector2
(
0
,
4
)
}
getShootPoint
()
{
return
new
FYGE
.
Point
(
this
.
x
+
this
.
width
/
2
,
this
.
y
+
this
.
height
)
}
}
\ No newline at end of file
src/Hero.ts
View file @
3442846d
import
DragDropable
from
"./dragdrop/DragDropable"
;
import
Vector2
from
"./lib/Vector2"
;
import
MovableManager
from
"./MovableManager"
;
import
{
IWeaponHost
}
from
"./weapon/IWeaponHost"
;
import
Weapon
from
"./weapon/Weapon"
;
...
...
@@ -15,6 +16,8 @@ export default class Hero extends DragDropable implements IWeaponHost {
const
weapon
=
new
Weapon
(
this
);
}
getShootVelocity
(){
return
new
Vector2
(
0
,
-
4
)}
getShootPoint
()
{
return
new
FYGE
.
Point
(
this
.
x
+
this
.
width
/
2
,
this
.
y
)
}
...
...
src/MovableManager.ts
View file @
3442846d
...
...
@@ -28,6 +28,7 @@ export default class MovableManager {
if
(
this
.
calcCanRemove
(
item
))
{
this
.
_movableList
.
splice
(
index
,
1
);
index
--
;
item
.
destroy
();
}
}
}
...
...
src/addGame.ts
View file @
3442846d
import
DragDropable
from
"./dragdrop/DragDropable"
;
import
DragDropManager
from
"./dragdrop/DragDropManager"
;
import
Enemy
from
"./Enemy"
;
import
Hero
from
"./Hero"
;
import
Vector2
from
"./lib/Vector2"
;
import
MovableManager
from
"./MovableManager"
;
export
function
addGame
(
stage
:
FYGE
.
Stage
)
{
...
...
@@ -8,7 +10,11 @@ export function addGame(stage: FYGE.Stage) {
const
dragDropManager
=
new
DragDropManager
();
const
hero
=
stage
.
addChild
(
new
Hero
(
movableManager
))
as
DragDropable
;
dragDropManager
.
add
(
hero
);
hero
.
position
.
set
(
300
,
1000
);
const
enemy
=
stage
.
addChild
(
new
Enemy
(
movableManager
));
enemy
.
position
.
set
(
0
,
0
);
enemy
.
velocity
=
new
Vector2
(
1
,
1
);
dragDropManager
.
add
(
hero
);
}
\ No newline at end of file
src/weapon/IWeaponHost.ts
View file @
3442846d
import
Vector2
from
"../lib/Vector2"
;
import
MovableManager
from
"../MovableManager"
;
export
interface
IWeaponHost
extends
FYGE
.
Sprite
{
movableManager
:
MovableManager
;
getShootPoint
():
FYGE
.
Point
;
getShootVelocity
():
Vector2
;
}
\ No newline at end of file
src/weapon/Weapon.ts
View file @
3442846d
...
...
@@ -30,9 +30,9 @@ export default class Weapon {
}
createBullet
=
()
=>
{
console
.
log
(
'
发射了一个
子弹'
)
console
.
log
(
'
武器在发射
子弹'
)
const
bullet
:
Movable
=
this
.
_host
.
parent
.
addChild
(
new
Bullet
());
bullet
.
velocity
=
new
Vector2
(
0
,
-
4
);
bullet
.
velocity
=
this
.
_host
.
getShootVelocity
(
);
const
shootPoint
=
this
.
_host
.
getShootPoint
();
bullet
.
position
.
set
(
shootPoint
.
x
,
shootPoint
.
y
);
this
.
_host
.
movableManager
.
add
(
bullet
);
...
...
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