Construct2/3

创建于:2017-02-24

创建人: iconboy

103 信息 416 成员
Construct2/3 引擎开发专题

游戏中加入计时器(倒计时效果)

鑫晴 2017-05-26

在游戏中加入计时器的效果

事件如图:

2个变量

  • MaxTimer:最大时间
  • TImer:当前时间

判断变量

  • 如果 Timer > 0
    • Timer -= 1 * dt      
  • 如果 Timer < 0
    • Timer = 0

什么是 dt

dt

Delta-time in seconds,即帧数,代表游戏时间表执行每一步所耗的时间。在一个 60FPS 的游戏中,dt 的值为1/60秒。

Set Text

zeropad(floor(Timer/60%60), 2) & ":" & zeropad(floor(Timer%60), 2)

这条指令中包含着几个方法

补零

zeropad(number, digits)Pad number out to a certain number of digits by adding zeroes in front of the number, then returning the result as a string. For example, zeropad(45, 5) returns the string "00045".

向下取整,去除小数

floor(x) Round down x e.g. floor(5.9) = 5

求时间分数

time/60%60

求时间秒数

time%60

近期喜欢的会员

 
totoyan 2017-06-01

这个可以!感谢dalao分享!

 
顾公 2017-06-30

有用,谢谢分享

 

加入 indienova

  • 建立个人/工作室档案
  • 建立开发中的游戏档案
  • 关注个人/工作室动态
  • 寻找合作伙伴共同开发
  • 寻求线上发行
  • 更多服务……
登录/注册