0
我正在研究一個由連續問題組成的簡單遊戲,並在30個問題結束時將該頁面重定向到另一個頁面(從遊戲操作到結束問題控制器操作)。我很難在javascript中創建一個倒數計時器(這將限制總遊戲時間爲240秒,並顯示向玩家倒計時),其中保持計數器值之間的倒數連續回答帖子到問題。 (即當遊戲開始時,它從240開始計數,當第一個問題被回答併發布時,第二個問題將被呈現並且倒數計時器將從240-(第一個問題花費的時間)等等繼續。)Zend倒數計時器
public function playAction() {
$sess = new Zend_Session_Namespace("mysession");
$qlist = $sess->qlist;
$qindex = $sess->currentQuestion;
$form = new Application_Form_QuestionForm();
if ($this->getRequest()->isPost()) {
$formData = $this->getRequest()->getPost();
if ($form->isValid($formData)) {
$ans = $form->getValue('Answer');
$uid = Zend_Auth::getInstance()->getIdentity()->id;
$qid = $qlist[$qindex]['id'];
$qtype = $qlist[$qindex]['type'];
$model = $this->_getUserQuestionModel();
$model->addMe($uid, $qid, $qtype, $ans);
$qindex++;
$sess->currentQuestion = $qindex;
} else {
$form->populate($formData);
}
}
if ($qindex > 29) { // all questions were asked
$this->_helper->redirector('finish');
}
$this->view->form = $form;
$this->view->qname = "Question " . ($qindex + 1) . ": " . $qlist[$qindex]['verb'] . " ---> " . $qlist[$qindex]['passive'];
}
感謝,