| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2249 人关注过本帖
标题:如何随机移动???
只看楼主 加入收藏
mywisdom88
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:191
帖 子:3146
专家分:8408
注 册:2015-3-25
收藏
得分:5 
回复 8楼 FunnyClown
** test.prg
of = CREATEOBJECT("form1")
of.show(1)

DEFINE CLASS form1 AS form
    ADD OBJECT shape1 AS shape WITH Top=10,Left=10,Height=70,Width=70,Curvature=99
    ADD OBJECT timer1 AS timer WITH Interval=500
    mTop = 0
    mLeft = 0
   
    PROCEDURE init
        this.mTop = this.Height - this.shape1.Height
        this.mLeft = this.Width - this.shape1.Width
    ENDPROC
   
    PROCEDURE timer1.Timer
        thisform.shape1.top = INT(thisform.mTop * RAND())
        thisform.shape1.left = INT(thisform.mLeft * RAND())
    ENDPROC
ENDDEFINE

**上面的是.PRG文件,你把上面的保存为 test.prg直接运行

** 如果你是在表单中的,那就这样
** 表单的 INIT中
PUBLIC mTop,mLeft
mTop = thisform.Height - thisform.shape1.Height
mLeft = thisform.Width - thisform.shape1.Width

** 在Timer1.Timer中
thisform.shape1.top = INT(mTop * RAND())
thisform.shape1.left = INT(mLeft * RAND())

2017-12-15 19:25
klearnh
Rank: 2
等 级:论坛游民
威 望:1
帖 子:105
专家分:80
注 册:2017-12-25
收藏
得分:0 
解释很详细啊。顺便学习了。
2017-12-25 15:55
快速回复:如何随机移动???
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017001 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved