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
cc0f1529
Commit
cc0f1529
authored
Nov 19, 2021
by
wildfirecode13
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
1c1d7c4e
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
85 additions
and
8 deletions
+85
-8
Hero.ts
src/Hero.ts
+22
-3
Movable.ts
src/Movable.ts
+1
-1
MovableManager.ts
src/MovableManager.ts
+1
-1
addGame.ts
src/addGame.ts
+7
-1
DragDropManager.ts
src/dragdrop/DragDropManager.ts
+0
-2
Vector2.ts
src/lib/Vector2.ts
+0
-0
IWeaponHost.ts
src/weapon/IWeaponHost.ts
+6
-0
Weapon.ts
src/weapon/Weapon.ts
+48
-0
No files found.
src/Hero.ts
View file @
cc0f1529
export
default
class
Hero
extends
FYGE
.
Sprite
{
import
DragDropable
from
"./dragdrop/DragDropable"
;
constructor
()
{
import
MovableManager
from
"./MovableManager"
;
import
{
IWeaponHost
}
from
"./weapon/IWeaponHost"
;
import
Weapon
from
"./weapon/Weapon"
;
export
default
class
Hero
extends
DragDropable
implements
IWeaponHost
{
movableManager
:
MovableManager
;
constructor
(
movableManager
)
{
super
();
super
();
this
.
texture
=
FYGE
.
Texture
.
fromUrl
(
'//yun.duiba.com.cn/spark/assets/enemy2_fly1.0f4acd3728e90763d98a7328a5a32dbc78ec204e.png'
)
this
.
movableManager
=
movableManager
;
this
.
texture
=
FYGE
.
Texture
.
fromUrl
(
'//yun.duiba.com.cn/spark/assets/hero_fly1.f292cb1c04589c6ee395fe29538d5385540755f7.png'
);
const
weapon
=
new
Weapon
(
this
);
}
}
getShootPoint
()
{
return
new
FYGE
.
Point
(
this
.
x
+
this
.
width
/
2
,
this
.
y
)
}
getDropPoint
()
{
return
{}
}
onDragEnd
()
{
}
}
}
\ No newline at end of file
src/Movable.ts
View file @
cc0f1529
import
Vector2
from
"./Vector2"
;
import
Vector2
from
"./
lib/
Vector2"
;
export
default
class
Movable
extends
FYGE
.
Sprite
{
export
default
class
Movable
extends
FYGE
.
Sprite
{
private
_velocity
:
Vector2
;
private
_velocity
:
Vector2
;
...
...
src/MovableManager.ts
View file @
cc0f1529
...
@@ -11,7 +11,7 @@ export default class MovableManager {
...
@@ -11,7 +11,7 @@ export default class MovableManager {
onEnterFrame
=
()
=>
{
onEnterFrame
=
()
=>
{
this
.
step
();
this
.
step
();
this
.
checkRemove
();
this
.
checkRemove
();
console
.
log
(
'移动对象的数量:'
,
this
.
_movableList
.
length
)
//
console.log('移动对象的数量:',this._movableList.length)
}
}
private
calcCanRemove
(
item
:
FYGE
.
DisplayObject
)
{
private
calcCanRemove
(
item
:
FYGE
.
DisplayObject
)
{
...
...
src/addGame.ts
View file @
cc0f1529
import
DragDropable
from
"./dragdrop/DragDropable"
;
import
DragDropManager
from
"./dragdrop/DragDropManager"
;
import
Hero
from
"./Hero"
;
import
Hero
from
"./Hero"
;
import
MovableManager
from
"./MovableManager"
;
import
MovableManager
from
"./MovableManager"
;
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
hero
=
stage
.
addChild
(
new
Hero
());
const
hero
=
stage
.
addChild
(
new
Hero
(
movableManager
))
as
DragDropable
;
dragDropManager
.
add
(
hero
);
hero
.
position
.
set
(
300
,
1000
);
}
}
\ No newline at end of file
src/dragdrop/DragDropManager.ts
View file @
cc0f1529
...
@@ -3,7 +3,6 @@ import DragDropEvent from "./DragDropEvent";
...
@@ -3,7 +3,6 @@ import DragDropEvent from "./DragDropEvent";
//管理一个拖放实例
//管理一个拖放实例
export
default
class
DragDropManager
extends
FYGE
.
EventDispatcher
{
export
default
class
DragDropManager
extends
FYGE
.
EventDispatcher
{
//初始化拖放对象事件
//初始化拖放对象事件
public
add
(
item
:
DragDropable
)
{
public
add
(
item
:
DragDropable
)
{
item
.
addEventListener
(
'DROP'
,
this
.
onDisplayItemDrop
,
this
)
item
.
addEventListener
(
'DROP'
,
this
.
onDisplayItemDrop
,
this
)
...
@@ -36,5 +35,4 @@ export default class DragDropManager extends FYGE.EventDispatcher {
...
@@ -36,5 +35,4 @@ export default class DragDropManager extends FYGE.EventDispatcher {
drag
.
onDragEnd
(
drop
);
drag
.
onDragEnd
(
drop
);
this
.
dispatchEvent
(
DragDropEvent
.
DRAG_END
,
{
drop
,
drag
});
this
.
dispatchEvent
(
DragDropEvent
.
DRAG_END
,
{
drop
,
drag
});
}
}
}
}
\ No newline at end of file
src/Vector2.ts
→
src/
lib/
Vector2.ts
View file @
cc0f1529
File moved
src/weapon/IWeaponHost.ts
0 → 100644
View file @
cc0f1529
import
MovableManager
from
"../MovableManager"
;
export
interface
IWeaponHost
extends
FYGE
.
Sprite
{
movableManager
:
MovableManager
;
getShootPoint
():
FYGE
.
Point
;
}
\ No newline at end of file
src/weapon/Weapon.ts
0 → 100644
View file @
cc0f1529
import
Bullet
from
"../Bullet"
;
import
Vector2
from
"../lib/Vector2"
;
import
Movable
from
"../Movable"
;
import
{
IWeaponHost
}
from
"./IWeaponHost"
;
export
default
class
Weapon
{
onCreateBullet
:
Function
_timer
;
_count
;
_host
:
IWeaponHost
;
constructor
(
host
)
{
this
.
_host
=
host
;
this
.
_timer
=
setInterval
(
this
.
onTimer
,
10
);
this
.
reset
();
}
reset
()
{
this
.
_count
=
0
;
}
onTimer
=
()
=>
{
this
.
_count
++
;
if
(
this
.
canCreateBullet
())
{
this
.
createBullet
();
this
.
reset
();
}
}
canCreateBullet
()
{
return
this
.
_count
>=
this
.
getShootInterval
();
}
createBullet
=
()
=>
{
console
.
log
(
'发射了一个子弹'
)
const
bullet
:
Movable
=
this
.
_host
.
parent
.
addChild
(
new
Bullet
());
bullet
.
velocity
=
new
Vector2
(
0
,
-
4
);
const
shootPoint
=
this
.
_host
.
getShootPoint
();
bullet
.
position
.
set
(
shootPoint
.
x
,
shootPoint
.
y
);
this
.
_host
.
movableManager
.
add
(
bullet
);
}
getShootInterval
()
{
return
20
;
}
destroy
()
{
clearInterval
(
this
.
_timer
);
}
}
\ 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