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
f2407cef
Commit
f2407cef
authored
Nov 19, 2021
by
wildfirecode13
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
3442846d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
6 deletions
+11
-6
Enemy.ts
src/Enemy.ts
+5
-0
MovableManager.ts
src/MovableManager.ts
+5
-5
addGame.ts
src/addGame.ts
+1
-1
No files found.
src/Enemy.ts
View file @
f2407cef
...
...
@@ -15,6 +15,11 @@ export default class Enemy extends Movable implements IWeaponHost {
this
.
texture
=
FYGE
.
Texture
.
fromUrl
(
'//yun.duiba.com.cn/spark/assets/enemy2_fly1.0f4acd3728e90763d98a7328a5a32dbc78ec204e.png'
)
const
weapon
=
new
Weapon
(
this
);
this
.
addEventListener
(
FYGE
.
Event
.
REMOVED_FROM_STAGE
,
()
=>
{
console
.
log
(
'敌人消失了'
)
weapon
.
destroy
();
})
}
getShootVelocity
()
{
return
new
Vector2
(
0
,
4
)
}
...
...
src/MovableManager.ts
View file @
f2407cef
...
...
@@ -11,14 +11,14 @@ export default class MovableManager {
onEnterFrame
=
()
=>
{
this
.
step
();
this
.
checkRemove
();
//
console.log('移动对象的数量:',this._movableList.length)
console
.
log
(
'移动对象的数量:'
,
this
.
_movableList
.
length
)
}
private
calcCanRemove
(
item
:
FYGE
.
DisplayObject
)
{
if
(
item
.
y
>
1624
)
return
true
;
if
(
item
.
y
<
-
item
.
height
)
return
true
;
if
(
item
.
x
>
750
)
return
true
;
if
(
item
.
x
<
-
item
.
width
)
return
true
;
if
(
item
.
y
<
-
item
.
height
)
return
true
;
if
(
item
.
x
>
750
)
return
true
;
if
(
item
.
x
<
-
item
.
width
)
return
true
;
return
false
;
}
...
...
@@ -27,8 +27,8 @@ export default class MovableManager {
const
item
=
this
.
_movableList
[
index
];
if
(
this
.
calcCanRemove
(
item
))
{
this
.
_movableList
.
splice
(
index
,
1
);
item
.
parent
&&
item
.
parent
.
removeChild
(
item
);
index
--
;
item
.
destroy
();
}
}
}
...
...
src/addGame.ts
View file @
f2407cef
...
...
@@ -14,7 +14,7 @@ export function addGame(stage: FYGE.Stage) {
const
enemy
=
stage
.
addChild
(
new
Enemy
(
movableManager
));
enemy
.
position
.
set
(
0
,
0
);
enemy
.
velocity
=
new
Vector2
(
1
,
1
);
enemy
.
velocity
=
new
Vector2
(
4
,
1
);
dragDropManager
.
add
(
hero
);
}
\ 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