动态文字显示问题,不知是否可行

zodane 2005-10-30 09:45:29
各位高手 ,你们好
本人在做游戏中, 现在有一个这样的问题, 比如游戏里出现一重大事件(死亡)
即触发某一窗体, 然后会有一条文字出现在窗体上,
要求字是一个接一个显示在窗体上的标签里的, 貌似美文浏览器 ,不知道是否可以做。
...全文
120 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
fice_chen 2005-10-31
  • 打赏
  • 举报
回复
上面的"i<str.length"改为“i<=str.length”
fice_chen 2005-10-31
  • 打赏
  • 举报
回复
首先将要滚动显示的文字赋给一个字符串变量(设为str),假设在lable控件上显示这些文字,在timer_tick中用如下代码:
static i as int16
if i<str.length then
lable.text=str.substring(0,i)
i+=1
else
i=0
end if
dzx20008 2005-10-30
  • 打赏
  • 举报
回复
不行 楼上的楼上运行了吗? 必须用timer控件
northwolves 2005-10-30
  • 打赏
  • 举报
回复
呵呵,楼上风趣.
上官云峰 2005-10-30
  • 打赏
  • 举报
回复
当然可以,用timer控件,随着时间的改变
label1.caption="你"
label1.caption="你牺"
label1.caption="你牺牲"
label1.caption="你牺牲了"
。。。。。。。。。。。。。。。
faysky2 2005-10-30
  • 打赏
  • 举报
回复
说错了,应该是 如果想窗体一装载就开始显示,那直接这样:
....
faysky2 2005-10-30
  • 打赏
  • 举报
回复
如果不想窗体一装载就开始显示,那直接这样:
Private Sub Form_Load()
Timer1.Interval = 50
starTime = GetTickCount
i = 1
Label1.Caption = ""
End Sub

Private Sub Timer1_Timer()
Dim strTip As String
strTip = "你挂啦!哈哈!"
If (GetTickCount - starTime) > i * 1000 Then
Label1.Caption = Label1.Caption & Mid(strTip, i, 1)
i = i + 1
End If
End Sub
zodane 2005-10-30
  • 打赏
  • 举报
回复
我把原先 form_load 里的代码写到 form _initicize
command_click 里的代码写到form_load没问题吧 .
呵呵, 循环是必然的啊.
只是除了循环 ,还设计字符处理函数嘛 ,后者我不大熟悉啊 :)
多谢指教 !!!
上官云峰 2005-10-30
  • 打赏
  • 举报
回复
我只是给你个方法,难道你不会循环吗?
faysky2 2005-10-30
  • 打赏
  • 举报
回复
改进:
Private Declare Function GetTickCount Lib "kernel32" () As Long

Dim starTime As Long, i As Long
Private Sub Command1_Click()
Timer1.Interval = 50
starTime = GetTickCount
i = 1
Timer1.Enabled = True
End Sub

Private Sub Form_Load()
Timer1.Enabled = False
Label1.Caption = ""
End Sub

Private Sub Timer1_Timer()
Dim strTip As String
strTip = "你挂啦!哈哈!"
If (GetTickCount - starTime) > i * 1000 Then
Label1.Caption = Label1.Caption & Mid(strTip, i, 1)
i = i + 1
End If
End Sub
faysky2 2005-10-30
  • 打赏
  • 举报
回复
Private Declare Function GetTickCount Lib "kernel32" () As Long

Dim starTime As Long
Private Sub Command1_Click()
Timer1.Interval = 1000
Timer1.Enabled = True
starTime = GetTickCount
Label1.Caption = "你"
End Sub

Private Sub Form_Load()
Timer1.Enabled = False
End Sub

Private Sub Timer1_Timer()
If (GetTickCount - starTime) > 1000 Then
Label1.Caption = "你挂"
End If
If (GetTickCount - starTime) > 2000 Then
Label1.Caption = "你挂啦"
End If
If (GetTickCount - starTime) > 3000 Then
Label1.Caption = "你挂啦!哈"
End If
If (GetTickCount - starTime) > 4000 Then
Label1.Caption = "你挂啦!哈哈!"
End If
End Sub
zodane 2005-10-30
  • 打赏
  • 举报
回复
靠, 不是吧 ,20个字,那不要20行代码啊。。。。。。。
大哥你就别为难我撒。。。 痛啊。。。

1,451

社区成员

发帖
与我相关
我的任务
社区描述
VB 控件
社区管理员
  • 控件
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧