首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Adobe Director - Lingo测验

Adobe Director - Lingo测验
EN

Stack Overflow用户
提问于 2013-03-08 10:25:28
回答 3查看 1.1K关注 0票数 0

所以我有一个用Adobe director做的测验,但我在整个环境中挣扎着。

我将下面的Lingo脚本添加到每个按钮,并给出正确的答案:

代码语言:javascript
复制
  on mouseDown
    global gscore
    set gscore = gscore + 1

在最后阶段,我使用以下Lingo脚本检查获取的点,并为结果显示适当的sprite。

代码语言:javascript
复制
on enterFrame
  if gscore = 0 then set the memberNum of sprite (3) to 154
end if
  if gscore = 1 then set the memberNum of sprite (3) to 155
end if
  if gscore = 2 then set the memberNum of sprite (3) to 156
end if
  if gscore = 3 then set the memberNum of sprite (3) to 157
end if
  if gscore = 4 then set the memberNum of sprite (3) to 158
end if
  if gscore = 5 then set the memberNum of sprite (3) to 159
end if
end

所以我的错误似乎是说没有声明的变量,但它是全局的,对吗?那它怎么会认不出来呢。第一个脚本附加到与正确答案对应的按钮上,每个按钮都有一个单独的脚本将其发送到下一个问题。用于显示结果的最后一个阶段应该根据gscore的值显示特定的自定义精灵。

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2013-03-08 11:26:03

我想通了,道歉。

我删除了所有的end if s,使其成为一个完整的if语句。在使用的第一个脚本上设置全局变量,将值声明为0。然后,当递增时,它会添加到先前定义的同名全局变量中。

我认为我的问题在于全局变量实例的默认值是空的。

票数 0
EN

Stack Overflow用户

发布于 2013-03-09 22:35:29

很高兴你想出了解决方案。另一种方法是根本不使用if语句。您的enterframe脚本可能如下所示:

在enterframe sprite上(3).memberNum= 154+gscore end

票数 1
EN

Stack Overflow用户

发布于 2014-01-28 13:14:29

代码语言:javascript
复制
on exitframe me
   global gscore

代码语言:javascript
复制
if gscore = 0 
   set the memberNum of sprite (3) to 154
else  if gscore = 1 then 
    set the memberNum of sprite (3) to 155
else if gscore = 2 then 
   set the memberNum of sprite (3) to 156
else if gscore = 3 then 
    set the memberNum of sprite (3) to 157
else if gscore = 4 then 
    set the memberNum of sprite (3) to 158
else  if gscore = 5 then 
  set the memberNum of sprite (3) to 159
end if

end
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15285657

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档