I am taking an object-oriented approach to building a Javascript app. For starters, I am creating a Game object and a Timer object.
Here s my current implementation: The Timer object has the following methods:
setTimerValue()
start()
stop()
getTimeLeft()
timeExpired()
The Game object has the following methods:
reset()
run()
...
Timer.start()
uses window.setInterval()
to start the countdown.
When the countdown gets to zero, it calls Timer.timeExpired()
.
<代码>timer.timeExpired(>>宣布,游戏已经结束,应当打电话Game.reset(
和Game.run(<>
,以重新开始游戏。 但是,如果时间客人不了解任何关于猎物的内容,如何做到这一点?
动物目标是否需要成为一种全球性的变数,才能发挥作用?
此外,目前,该动物物体的特性之一为时标。 这使得狩猎者反对使用时间方法。 但是,不清楚时间方法如何能把猎物称作猎物。
I have a nagging suspicion that I am creating too many dependencies between the objects and could use some suggestions on how to architect this better.
Thanks everyone.