Lingo基础视频教程.docx
《Lingo基础视频教程.docx》由会员分享,可在线阅读,更多相关《Lingo基础视频教程.docx(19页珍藏版)》请在冰豆网上搜索。
Lingo基础视频教程
Lingo基础视频教程学习笔记
01.01_CourseIntro:
介绍了教程概况和教学大纲。
01.02_WorkFiles:
介绍光盘中所含工程文件的借鉴使用方法。
01.03_WhatisLingo:
介绍什么是lingo语言,如何打开script窗口。
01.04_ScriptTypes:
介绍了四种类型的脚本,根据四种不同的对象类型(movie\frame\sprite\castmember)。
基于时间的脚本framescripts和moviescripts,基于空间的脚本spritescripts和castscripts。
01.05_WritingSimpleLingoScripts:
介绍了两个简单的实例,说明lingo的两种语法格式,一种是描述式的,一种是点式语法格式(类似其它高级语言)。
01.06_TheScriptWindow:
介绍脚本窗口的不同打开方式。
1、通过“window->script”菜单。
2、通过score窗口的scripts属性。
3、castmember通过castscript按钮。
4、framescript通过双击script通道。
介绍script窗口各个按钮的功能。
01.07_Comments:
介绍注释的功用和重要性。
01.08_TestingScriptswiththeMessageWindow:
介绍如何使用messagewindow调试和查看调试信息。
02.01_SpriteBehaviors:
介绍spritebehaviors(behaviorscripts)的编辑使用方法。
02.02_FrameBehaviors:
介绍framescripts的编辑使用方法。
02.03_CastMemberScripts:
介绍CastMemberScripts的编辑使用方法。
并演示了behavior和castmemberscripts的区别。
02.04_MovieScripts:
介绍moviescripts的编辑使用方法。
常用的prepareMovie\startMovie\stopMovie等方法。
moviescripts编写好之后不出现在score窗口或sprite中的任何位置,却可以执行相应功能,一旦写好之后Director随时可对它进行访问。
02.05_Events&EventHandlers:
介绍事件和事件句柄以及相应代码的使用方法,如ontimeout\onresizeWindow等。
02.06_PrimaryEventHandlers:
介绍了一些基本的事件如:
keyDownScriptkeyUpScripttimeoutScriptmouseUpScriptmouseDownScript,和其它事件不同,基本事件的句柄不是由on开始由end结束,两个例子说明了基本事件句柄的使用方法。
如setthemouseUpScriptto"put99"一句加入在message窗口中后,执行,点击一次鼠标,便会在message窗口中输出一次"99",再如:
在一段脚本中加入:
setthetimeoutLength=6*60
setthetimeoutScriptto"gotoframe100"
两句后会在运行时6秒钟无反应的情况下跳转到100帧。
02.07_CustomHandlers:
介绍了自定义的句柄,例如:
在一个按钮的spritebehavior的onmouseUp事件中加入了changeStageColor方法,则在一个moviescript中来自定义这个句柄如下:
onstartMovie
onchangeStageColor
setthestageColor=random(250)
updateStage
end
end
则在程序运行过程中点击按钮会改变当前stage颜色。
02.08_EventMessageHierarchy:
介绍事件消息的结构。
优先级由高到低顺序如下:
PrimaryEventHandlers
Sprites
CastMembers
Frames
Movies
当同时有数个事件发生时,高优先级的事件脚本获得执行,低优先级的被忽略。
还介绍了优先级按照结构顺序的传递。
02.09_ReviewwhatYouhaveLearned:
通过一个实例回顾了本章内容提到的各种脚本、事件和句柄。
03.01_Looping&PausingaMovie:
介绍如何控制程序停止在某一帧
onexitFrameme
gototheframe
end
或在当前帧和前一marker之间循环
onexitFrameme
goloop
end
03.02_JumpingtoNewFrames:
介绍如何跳转到某一特定帧。
如:
gotoframe30,或gonext/previous(跳转到后/前一marker)gotomarker
(2)(跳过2个marker)goto"marker1"(跳转到特定marker)
03.03_CreatingSmartNavigationScripts:
介绍如何跳转回前一位置。
设置两个按钮,一个在onmouseup句柄中加入play"marker1"跳转到特定位置,另一个加入playdone返回跳转前的位置。
此方法可实现在不同的movie之间跳转,如:
前者改为play"marker1"ofmovie"movie2"
03.04_Menus:
介绍了如何在程序中加入菜单。
在cast中加入一个文本型的castmember,内容如下:
Menu:
Navigation
Page1|goPage1
Page2|goPage2
Page3|goPage3
Page4|goPage4
Quit/Q|quit
再建立一个moviescript,内容为:
onstartMovie
installMenumember"myMenu"
ongoPage1
goto"Page1"
end
ongoPage2
goto"Page2"
end
ongoPage3
goto"Page3"
end
ongoPage4
goto"Page4"
end
end
则在运行时会有一个名为Navigation的菜单,其中有goPage1\goPage2\goPage3\goPage4\Quit五个选项,分别实现向名为Page1\Page2\Page3\Page4四个标签位置的跳转和退出功能,退出快捷键为Ctrl+Q。
03.05_ApplyingwhatYouhaveLearned:
通过一个综合实例介绍了本章内容的应用。
04.01_CreatingTransitions:
介绍通过script的方式添加的过渡效果的方法。
例如在onexitFrame句柄中加入语句_movie.puppetTransition(int,time,size,area)。
参数分别表示过渡的标识号,持续时间,颗粒大小,作用区域。
过渡标识号可以在帮助文档中通过puppetTransition来搜索到。
04.02_SettingTempo:
介绍可通过script改变播放速度,和在tempo通道设置等效。
例如
onexitFrameme
puppetTempo20
end
可调整速度为20fps。
04.03_SwappingSprites:
介绍如何通过script改变sprite演员为另一个角色(castmember)。
script语句为:
Sprite(spriteNum).memberNum=newNum
04.04_Rollovers:
介绍了Rollover事件可帮助我们实现的效果。
使用rollover返回鼠标悬停的演员的通道号,配合if语句实现鼠标悬停或经过时的效果。
两种使用方法1)therollover2)rollover(x),前者返回通道号,后者返回布尔值,判断是否悬停于x通道的演员上,如:
onexitFrameme
gototheframe
ifrollover
(1)thensprite
(1).membernum=6
endif
end
当鼠标经过sprit
(1)时,将通道中的演员改为角色6显示。
又如:
onexitframe
ifrollover
(2)then
gotoframe"end"
endif
gototheframe
end
当鼠标经过通道2上的演员时,跳转到"end"帧并停留。
04.05_ChangingtheCursor:
介绍如何改变鼠标光标外观。
使用cursorx其中x表示光标标识号。
如:
onstartmovie
cursor2
end
在此影片中将光标外观改为十字形。
其语法为:
sprite(20).cursor=4或setthecursorofsprite20to4将使光标经过sprite20时改变外观。
每个光标外观对应一个标识号。
04.06_CustomCursors:
介绍如何自定义光标外观。
可使用一个不大于16*16像素大小的黑白二值位图来自定义光标外观。
使用类似cursor[2]来应用自定义光标,[2]表示一个castmember。
和cursor2不同,cursor2表示标识号为2的系统默认光标,cursor[2]表示castmember为2的自定义光标。
如:
onexitFrameme
sprite
(1).cursor=[2]
gototheframe
end
04.07_AnimatedCursor:
介绍如何建立一个动画的光标。
在cast中建立几个位图member作为光标的不同状态(16*16或32*32),通过insert->MediaElememt->Cursor...打开光标属性编辑对话框,来利用castmember自定义动画光标。
则在cast中建立了一个动画光标的member,命名为"myCursor",在script中使用此光标如为一个按钮加入如下:
onmouseEnter
cursor(member"myCursor")
end
则在鼠标进入按钮上时,光标改变为自定义的动画光标。
04.08_CursorLocations:
介绍如何获得鼠标的位置。
themouseV和themouseH分别在script中返回鼠标当前的垂直和水平坐标。
如:
onmouseUp
Sprite
(1).locV=themouseV
end
实现点击鼠标后sprite
(1)的演员在水平方向和鼠标对齐(和鼠标取相同的纵坐标)。
04.09_ApplyingwhatYouhaveLearned:
通过一个实例介绍了如何控制score。
05.01_TriggeringSounds:
介绍如何控制音频通道的播放。
如:
onexitFrameme
sound(3).play(member"gitar")
end
实现在音频通道3中播放名为gitar的castmember。
缓冲的语法是sound(x).queue(member"gitar"),停止播放的语法是sound(x).stop(),另外还有fadein/fadeout方法。
ifsoundBusy(x)thensound(x).stop()实现对判断停止音频播放。
05.02_PuppetSounds:
简单回顾之前版本软件实现音频播放的方法puppetSound。
方法为:
puppetSound3,"button"实现播放名为button的音频在音频通道3中。
puppetSound3,0实现将通道的控制权交还给score。
05.03_ControllingSoundVolume:
介绍如何控制音频音量。
如:
onstartMovie
setthesoundLevel=4
end
实现对整体音量的控制。
或
onexitFrameme
sound(3).play(member,"track1")
setthevolumeofsound(3)=200
-sound(8).volume=200-另一种写法。
end
实现对特定通道音量的控制。
05.04_FadingSounds:
介绍如何实现音频淡入淡出效果。
语法为:
sound(whichchannel).fadeOut(milliseconds)如:
sound(3).fadeOut(1000)和sound3,1000等效。
又如:
onmouseUpme
sound(3).fadeIn(2000)
sound(3).play(member"gitar")
end
实现淡入音频gitar。
05.05_ControllingExternalSounds:
介绍如何控制外部音频文件播放。
如:
onexitFrameme
soundplayFile3,"gitarCue.aif"
end
实现对外部音频文件gitarCue.aif的播放,
onexitFrameme
puppetSound3,0
sound(3).stop()
gototheframe
end
实现对通道3当前音频文件的停止播放。
05.06_SynchronizingSound:
介绍利用音频文件中的cuepoint同步音频和动画。
如:
在message窗口中使用
putsound
(1).mostRecentCuepoint
来获取音频通道1中刚刚经过的cuepoint。
再如:
可以使用
onexitFrameme
Ifsound
(1).mostRecentcuePoint=2then
puppetTempo12
Endif
end
实现在经过一个音频节点时降低播放速度为12帧。
05.07_CheckingQuickTimeVersion:
介绍如何检测计算机上安装的QuickTime播放程序的版本。
如通过putquickTimeVersion()在消息窗口中获取当前机器上的QuickTime的版本。
再如:
onstartMovie
ifquickTimeVersion()<8then
alert"YouneedtoupgradeyourQuickTime"
endif
end
实现程序运行前对QuickTime版本的检查,若小于8则提示升级。
05.08_ControllingQuickTimeMovies:
介绍如何控制quicktime电影的播放。
如:
oneixtFrameme
sprite
(2).loopBounds=[(1*60),(5*60)]
end
实现sprite2通道的影片循环播放1-5秒之间。
05.09_MovieRate:
介绍如何控制特定通道中数字视频的播放速度。
如:
onexitFrameme
gototheframe
setthemovieRateofsprite1to-1
--sprite(3).movieRate=5--点式语法形式。
end
实现对播放速度的控制,1表示播放,0表示停止,-1表示倒放,高于1表示快放。
05.10_MovieTimeSkipping:
介绍如何跳到视频播放的特定位置。
视频播放时每秒钟被分为60个时间单位。
可以通过消息窗口的putsprite
(1).movieTime在程序运行时获取影片播放的精确时间。
又如:
onexitFrameme
ifthemovieTimeofsprite1>50then
setthemovieTimeofsprite1to4000
endif
end
实现对视频播放的跳转。
05.11_FrameRate:
介绍如何控制成员的播放帧速率。
05.12_CroppingVideo:
介绍了视频成员的裁切属性。
可以通过属性面板来开关裁切属性,也可以通过lingo来进行。
如:
member("videoSample").crop=FALSE/TRUE表示当从视频sprite的右下角控制点进行鼠标拖拉时进行放缩或裁切。
Translation属性,意思似乎是当crop属性为TRUE时,可以通过此属性使sprite的矩形边框成为一个蒙板,当赋予偏移量参数时,sprite相对矩形边框的左上角有一个偏移,默认偏移量为零。
如:
sprite(5).translation=[10,0]
05.13_ApplyingwhatYouhaveLearned:
通过一个实例介绍本章内容的应用。
06.01_Commands:
介绍lingo中的命令和普通命令格式。
06.02_Functions:
介绍函数的概念。
注意区别:
mouseDown是事件(event),onmouseDown是句柄,themouseDown是函数。
06.03_Keywords:
介绍lingo中的关键词。
06.04_ConditionsandStatus:
介绍了条件语句和状态关键词ture/false。
如:
OnkeyDown
Ifthekey="a"thengotoframe"a"
Ifthekey="b"thengotoframe"b"
Ifthekey="c"thengotoframe"c"
endif
实现根据按键状态跳转。
还可依次实现更复杂的逻辑结构。
06.05_properties:
介绍了lingo中的属性。
通常的改变属性的方法为:
PutSprite(whichSprite).someProperty=somevalue
根据条件设置属性的方法为:
ifsomeProperty=someValuethendosomething如:
ifthesoundLevel=5then
setthesouneLevel=4
endif
属性类型分类:
System/Movie/Sprite/CastMember/Sound/Video.
06.06_Constants:
介绍了lingo中的常量。
TURE/FALSE/VOID/EMPTY/BACKSPACE/ENTER/QUOTE/RETURN/SPACE/TAB.
06.07_Operators:
介绍了lingo中的运算符。
06.08_JavaScriptSyntax:
简单介绍了JavaScript的语法在lingo中的应用方法。
06.09_Review:
回顾了本章内容。
07.01_IfThenStatements:
介绍了ifthen的条件语句结构。
07.02_IfThenElseIfStatements:
介绍ifthenelse结构。
如:
onexitFrameme
gototheframe
ifrollover
(1)thensprite
(1).membernum=6
elsesprite
(1).memberNum=5
endif
end
07.03_RepeatConstructs:
介绍repeat结构。
如:
onexitframeme
repeatwithn=5downto3
sprite(n).forecolor=200
endrepeat
gototheframe
end
07.04_Repeatwithdownto:
介绍repeatwithdownto的结构。
如上例。
07.05_CaseStatement:
介绍case结构。
如:
onexitFrameme
case_movie.rollOver()of
1:
sound
(1).play(member("hron"))
2:
sound
(1).play(member("Drum"))
3:
sound
(1).play(member("Bongos"))
4:
sound
(1).play(member("Bass"))
5:
sound
(1).play(member("Gitar"))
endcase
end
实现根据鼠标悬停位置播放不同的声音文件。
07.06_applyingwhatyouhavelearned:
介绍了本章内容的简单应用。
08.01_WhatareVariables:
介绍了lingo中的变量。
08.02_GlobalVariables:
介绍lingo中的全局变量。
用于存储全局变量数据,变量名通常加前缀“g”以便于识别。
变量在StartMovie句柄中声明并设置。
必须事先声明。
08.03_LocalVariables:
介绍lingo中的局部变量。
只在当前句柄运行范围内有效。
用于保存临时变量。
08.04_ArgumentsandPassedValues:
介绍lingo中用到的参数。
如:
onaddThema,b
c=a+b
returnc
end
08.05_DataTypes:
介绍了lingo中的数据类型。
数值、字符、布尔、符号、列表、运算结果等6种。
08.05_UsingVariablesinYourScript:
通过一段代码实例介绍了变量的使用。
09.01_CheckingSpriteProperties:
介绍如何察看sprite的属性。
如:
onstartMovie
ontestCondition
Sprite
(2).foreColor=random(5)
Ifsprite
(2).foreColor=1thenmember
(2).text="LightBlue"
Ifsprite
(2).foreColor=2thenmember
(2).text="Purple"
Ifsprite
(2).foreColor=3thenmember
(2).text="DarkBlue"
Ifsprite
(2).foreColor=4thenmember
(2).text="Yellow"
Ifsprite
(2).foreColor=5thenmember
(2).text="Green"
UpdateStage
end
end
实现判断颜色功能,在一个按钮的属性中加入:
onmouseUpme
testCondition
end
则点击按钮会改变颜色并进行判断。
09.02_SpriteColorationForecolor:
介绍如何改变sprite或castmember的颜色属性。
可对text对象的特定单词改变颜色。
如:
onexitFrameme
gototheframe
member("myText").line