上一篇 | 下一篇

关于多定时器

发布: 2007-1-25 17:02 | 作者: cjx2000 | 来源: aougu.com | 查看: 142次

  做游戏多定时器是非常重要。但Director的新加的定时器不合适游戏编写,不过可以编慢速的游戏。长话我不说,主要讨论一下这三个相关的属性:
O O l#Uf'R/\   1. the timer奥古多媒体xh0e^$e;u
  2. the ticks奥古多媒体md-_1OQQ6I-w
  3. the milliseconds
|] z g;A[2t A 奥古多媒体0Y Tid6jj
  从测试中发觉 the milliseconds 更合适,计算更精细。在帧循环中使用更合适,也就解决了速度问题。奥古多媒体+v?(rKx*^v.H
奥古多媒体g G"JEW)F(}8pP
property pTime
WP4fg:Yf
2o2vS E!D[cr on prepareframe me奥古多媒体IZ)iBB%]-G8[ V
  if ( the milliseconds – pTime > 1000 ) then
y,VfH6S z_     pTime = the milliseconds奥古多媒体&fC-K:gx/\ l5|
    执行内容...奥古多媒体KJE.oS u.j kR
  end if
G `4] {_-@V6{,pd end奥古多媒体4\*rJ1J+d0M}ZH

(J-~_Zg [(kB 一开始就定时计算奥古多媒体Y)Ml [J1gM Po
奥古多媒体a0R~+B*LQt4tA
property pTime
d'Z ]H;rSvx
_+c8V lo'l on beginsprite me奥古多媒体U'w#m;p]@ ]J
  pTime = the milliseconds奥古多媒体_w"]!kT}
end
H[R~TLN 奥古多媒体7aT X0w P'Tf
on prepareframe me
GZcR{'?   if ( the milliseconds – pTime > 1000 ) then 奥古多媒体;v#_Y:J5i3v5v
    pTime = the milliseconds奥古多媒体/Lc5u&n(W4lz,~
    执行内容...奥古多媒体,Qp^ u,kC
  end if
Olw(v4_8bD end
A K|O4i_5z"R4d 奥古多媒体,i*[S|L n^
增加多定时器奥古多媒体V8S b6{pA? m1^Y
奥古多媒体{sRWd5ED1[
property pTime
7q6}2lK7|U)W property pTime2
/}QzaA7qA
~6H3H$j1c@9]:L on beginsprite me奥古多媒体FtA/ap
  pTime = the milliseconds奥古多媒体4NB O vST
  pTime2 = the milliseconds
R1R~:`P\i,] end
LGq%\C+rO|&B~
&H2o!gids;p on prepareframe me奥古多媒体'W v3[S8cw8D?%t
  if ( the milliseconds – pTime > 1000 ) then
!FL.RZI5J1D     pTime = the milliseconds奥古多媒体7D*b6Q"A1q_2Ev+Vy
    执行内容...
.P:S`1t5Mot   end if
?M5o'C1Lj8G p/W V-Hv   if ( the milliseconds – pTime2 > 1000 ) then
(^]u(Agp8M$W     pTime2 = the milliseconds
[/WT#Ba3W}y     执行内容...奥古多媒体"F#n1jx~f(@
  end if
H.h sn-t J"z)J end
'Lq0ud:~R'^
{ g"J$[#B[~;|奥古多媒体:oy at}i)zA8a
奥古多媒体v:y N_ b J$v
property pTime奥古多媒体7OE*ULyh2iVJ[
property pTime2奥古多媒体T6yc U]:u*x
奥古多媒体xJ1H.f{4B'm3s
on prepareframe me奥古多媒体.q f-oQG&a
  if ( the milliseconds – pTime > 1000 ) then 奥古多媒体6ndB:y'BH T7y
    pTime = the milliseconds奥古多媒体%oa;NPDA
    执行内容...奥古多媒体b pbr*mh
  end if奥古多媒体r"HPQ R~
  if ( the milliseconds – pTime2 > 1000 ) then 奥古多媒体%o$n7Kz)[W
    pTime2 = the milliseconds奥古多媒体)h"xhz(\/w7RYt
    执行内容...
0sC"Jmou!pC   end if奥古多媒体|"l0Z_I#kQ6E0~,\3H]
end奥古多媒体 K f{*gZ)k3b(r:M2w {
奥古多媒体``2H/O@
  类推...

字号: | 推荐给好友

 

评分:0

我来说两句

seccode