File tree Expand file tree Collapse file tree 4 files changed +8
-0
lines changed Expand file tree Collapse file tree 4 files changed +8
-0
lines changed Original file line number Diff line number Diff line change 14
14
15
15
< title > Zombies</ title >
16
16
17
+ < script src ="https://code.createjs.com/1.0.0/tweenjs.min.js "> </ script >
17
18
< script src ="lib/keyboard.js "> </ script >
18
19
< script src ="lib/pixi.min.js "> </ script >
19
20
< script src ="lib/matter.min.js "> </ script >
Original file line number Diff line number Diff line change @@ -115,6 +115,8 @@ class Zombie {
115
115
{ x : force * damage * horzDelta * 1000 , y : force * damage * vertDelta * 1000 }
116
116
)
117
117
118
+ this . damage ( force )
119
+
118
120
setTimeout ( ( ) => ( this . stunned = false ) , ZOMBIE_STUNNED_DELAY )
119
121
}
120
122
@@ -128,10 +130,14 @@ class Zombie {
128
130
}
129
131
130
132
kill = ( ) => {
133
+ createjs . Tween . get ( this . sprite )
134
+ . to ( { alpha : 0 } , ZOMBIE_DEATH_ANIMATION_DELAY )
135
+ . call ( ( ) => this . game . getStage ( ) . removeChild ( this . sprite ) )
131
136
Matter . Composite . remove ( this . game . physicsEngine . world , this . rigidBody )
132
137
}
133
138
134
139
revive = ( ) => {
140
+ this . game . getStage ( ) . addChild ( this . sprite )
135
141
Matter . World . add ( this . game . physicsEngine . world , this . rigidBody )
136
142
}
137
143
}
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ const ZOMBIE_MAX_HEALTH = 50
22
22
23
23
const ZOMBIE_BASE_COUNT = 10
24
24
const ZOMBIE_INCR_COUNT = 4
25
+ const ZOMBIE_DEATH_ANIMATION_DELAY = 250 // ms
25
26
26
27
const PLAYER_TAG = 'MY MAN'
27
28
You can’t perform that action at this time.
0 commit comments