当前位置:软件学习 > Director >>

Director Lingo应用之repeat with

Director Lingo应用之repeat with


播放,以上示例,需下载此插件。 点击下载插件

repeat with (计数循环)

描述 : 我们可以根据设定变量的变化范围值,执行不同的命令句。

--------------------

语法

repeat with 变量 = 小的值 to 大的值
   命令句 1
   命令句 2
   命令句 3
   ...
end repeat

或是:

repeat with 变量 = 大的值 down to 小的值
   命令句 1
   命令句 2
   命令句 3
   ...
end repeat

说明 :

程序自动重复执行 repeat 及 end repeat 间的命令句
一共执行次数:大的值 - 小的值 + 1

示例 :

repeat with i = 0 to 10
   put i --把 I 的值输出到 message window
end repeat

--------------------

updateStage (对舞台的即时更新)

语法:

updateStage

说明:

如果使用 Lingo 在 repeat 的循环中改变精灵(sprite)的属性时,舞台画面并不会马上更新,必须使用 updateStage 这个指令告诉 Director 立即更新舞台

--------------------

示例: 图片淡入淡出的控制

效果

放置一个淡入的按钮及一个淡出的按钮,再放一张图片在舞台上,由淡入及淡出按钮來控制图片的淡入及淡出效果。

制作步骤如下:

1. 放置一张图片在Channel 1,两个按钮在Channel2、3

2. 在桢脚本中加入 go to the frame 使之循环播放

3. 选择"淡入"按钮,写入如下 Lingo:

on mouseUp me
repeat with i = 0 to 100
set the blend of sprite 1 = i
-- sprite(1).blend = i
updatestage
end repeat
end

4. 选择"淡出"按钮,写入如下 Lingo:

on mouseUp me
repeat with i = 100 down to 0
set the blend of sprite 1 = i
-- sprite(1).blend = i
updatestage
end repeat
end

提示 : blend 为图片的透明度,最高为 100,最低是 0。

相关附件

[1]

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,