心跳的感觉[控件移动]
本帖最后由 afan 于 2010-4-19 23:56 编辑没错,真的是心跳的感觉~~~ :face (13):
虽然最近很忙乱,但也要偷闲。让那个啥疼一下……
请教大家,能否让(附件中的)这颗心跳动得还自然一些?
;练习之界面代码:Dim $P = RegRead('HKLM\SOFTWARE\AutoIt v3\AutoIt', 'InstallDir')
Dim $Ico = $P & '\Aut2Exe\Icons\strawberry.ico'
GUICreate('test', 350, 130)
$cIco = GUICtrlCreateIcon($Ico, -1, 100, 100)
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $cIco
Msgbox(0, 0, '让心跳动起来')
EndSwitch
WEnd;
;以下是本菜鸟做的练习,不影响各位有心人的思路,特此隐藏~
;我想主要的问题是把握节奏的算法~ 但这个感觉貌似难把握~
**** Hidden Message ***** 沙发,这么晚了,来看看 来看看........:face (7): 来看看先 .................... 来看看先 .................... 来看看先 .................... 各位还不睡啊,天快亮了…… 插个FLASH:face (22): Dim $P = RegRead('HKLM\SOFTWARE\AutoIt v3\AutoIt', 'InstallDir')
Dim $Ico = $P & '\Aut2Exe\Icons\strawberry.ico'
GUICreate('test', 350, 130)
$cIco = GUICtrlCreateIcon($Ico, -1, -1,40, 35)
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $cIco
;Msgbox(0, 0, '让心跳动起来')
For $i=1 To 100
GUICtrlSetPos($cIco,0,1*$i,40,35)
Sleep(50)
Next
EndSwitch
WEnd 呵呵,看看先。。 插个FLASH
nmgwddj 发表于 2010-4-20 04:45 http://www.autoitx.com/images/common/back.gif
Flash是属于特殊的,自身会动。这里仅讨论下某种意义上的静态控件的规律移动~
如果能定义个2维数组(包含时间、高程),这个问题应该很简单。 上来就看见afan出了个好题,好玩就做了一个,按一下就不停的跳,再按一下停止,挺好玩的,哈哈~~
代码:
Dim $P = RegRead('HKLM\SOFTWARE\AutoIt v3\AutoIt', 'InstallDir')
Dim $Ico = $P & '\Aut2Exe\Icons\strawberry.ico'
GUICreate('test', 350, 130)
$cIco = GUICtrlCreateIcon($Ico, -1, 100, 50,32,32)
GUISetState()
$f=1
$g=0
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $cIco
;~ Msgbox(0, 0, '让心跳动起来')
$t=TimerInit ()
$g = Not $g
While $g
$nMsg = GUIGetMsg()
If $nMsg == -3 Then Exit
If $nMsg == $cIco Then
If $g Then MsgBox (0,"","你干嘛,会死人的!")
$g = Not $g
EndIf
$time = Round ( TimerDiff($t)/1000,1)*10
$jump = Mod ( $time, 10)
If $jump == 0 Then
GUICtrlDelete ($cIco)
$cIco = GUICtrlCreateIcon($Ico, -1, 95, 45,42,42)
Sleep (80)
GUICtrlDelete ($cIco)
$cIco = GUICtrlCreateIcon($Ico, -1, 100, 50,32,32)
EndIf
WEnd
EndSwitch
WEnd
回复 12# C.L
泡MM的好代码,哈~ 回复 13# afan
泡MM我倒是没想到,被你提醒了,哈哈~ 重在参与!#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Dim $P = RegRead('HKLM\SOFTWARE\AutoIt v3\AutoIt', 'InstallDir')
Dim $Ico = $P & '\Aut2Exe\Icons\strawberry.ico'
$hGui = GUICreate('test', 300, 300)
$cIcoa = GUICtrlCreateIcon($Ico, -1, 130, 150)
$cIcob = GUICtrlCreateIcon($Ico, -1, 130, 150, 40, 40)
GUICtrlSetState(-1, $GUI_HIDE)
GUISetState()
AdlibRegister('Mobile', 800)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case - 3
Exit
EndSwitch
WEnd
Func Mobile()
GUICtrlSetState($cIcoa, $GUI_HIDE)
GUICtrlSetState($cIcob, $GUI_SHOW)
Sleep(500)
GUICtrlSetState($cIcob, $GUI_HIDE)
GUICtrlSetState($cIcoa, $GUI_SHOW)
EndFunc ;==>Mobile