系统表达式用法级初步汉化版_第1页
系统表达式用法级初步汉化版_第2页
系统表达式用法级初步汉化版_第3页
系统表达式用法级初步汉化版_第4页
系统表达式用法级初步汉化版_第5页
已阅读5页,还剩13页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

欢迎加 1gbC2资C2比如你想知道精灵A到精灵B之间的距离你该怎么办,需要用到系统表达式里的distance(x1,y1,x2,y2)函数x1,y1表示A原点坐标x2,y2表示精灵B标在需要填写表达式的地方按下图写入表达式好了现在把c2系统系统表达本节概述了构造2中的内置System对象中的表达式。许多是常见的数算符,它们可以与“表达式”面板中的描述一起列出,但是这里包括它们是为了完整性。-System对象的表达式。有关如何在构造2中使用表达式的一般信息,请参阅表达式。显Windowsize;/TopRightBottom表达式。参见支持多种屏幕尺寸c2里指的对象是获取图层XYc2里指的对象是画布操作后立即使用-您只能在“在画布快照触发器之后使用”。)表达式返回图像文件的数据URI。这可以通过从URL加载图像,发送到服务器或本地,或通过新的选SpriteTiledBackground对象。获取通过设置布局缩放操作设置的整个布局的当前缩放。这不包括单个图层的缩c2里指的角度的函数以度0度开始朝右,顺时针增加。ABS(x)的x的绝对值ABS(-5)=anglelerp(A,B,x)的线性内插角度一b由点¯xlerp不同,这考虑到离结束小于步距离,则返回结束。ceil(x)x例如ceil(5.1)6cosp(a,b,x)abx。计算(A+B+(一-二)*COS(X*180°))/2。立方(,,,,)的一个bÇ和ð由点xep(apa,b,c,),r(,cd,x,x)距离(,1,,)x()计算e^xfoo()舍入x例如or59=5fnity表示无穷大的浮点数值。e(,,)a到bxa+x(-)。une(,b,)反向线性插值:如果lp(,,x=y,则ulr(,,y)=。计算(-a)ba)。()日志到x的ae。o1()x1。(,b,c)(,b,c)圆周率的数学常数pi319)qa(,,,)一个b和Ç由点xepepab,x,lpb,c,x),x)。oun()rndxrn(56=6sqr()计算x例如sr(5=5701。32x的第n位设置为b(01)3232xn0110.32保存并加在“”“上保存JN使用从JN载操加载。关息,请如何制作保存游戏。c2里指的对象是()WbL;如果nvaD0“R”,这不是格正确,因为非所有设都具有存。还要记住个表达不包括存使用,码其他非图资源。010.5,一半完成。有关详细信息,请参阅教程Construct2中创建自定义加载屏幕和离线游戏。渲染器c2里指的对用来绘制游戏中,无论是当前的渲染器的名称canvas2d或的。有关画布渲染器的信息,请参阅技术用于绘制游戏的图形硬件的名称,例如“NVIDIAGeGTX660”或“Adreno330”。这只在某些浏览器和平台的WebGL模式下可用;不支持的浏览器/系统将返回“(不可用)”GPU系GPU,或者查找关键字并根据硬件类型应用默认图形设置。c2里指的对象是find(src,left(text,返回第一个计数的字符文本返回文本中的字符数mid(text,index,返回计数启动字的索引中的文本处理正则表达式RegexonString,并在结果列表中返回Index处的条目过程中的正则表达式正则表达式的字符串与标志,并返回结果列表中的条目数rece(src,find,查找所有出现的发现在SRC和替换它们代表right(text,返回最后计数的字符文本tokenat(src,index,从返回的第NSRC,通过拆分字符串分隔符。例如,tokenat(“apples|oranges|bananas”,1,“|”)返回橙子。src中发生多少个令牌。例如,tokencount(“apples|oranges|bananas”,“|”)3。垫数出一定数目的位数由在数字前面加上零,那么返回结果为字符串。(45,5)返回字符串“00045”c2里指的对象是GPU上,因此这种测量不能告诉你任何关于渲染的速度或速度fps是一个更好的措施。还要注意,这个测量是基于计时器,所以应该被当作Javascript线程时间。当前帧每秒(FPS)60fps,c2里指的对choose(a,b[,随机选择一个给定的参数。例如,选择(1,3,9,20)随机选择四个数字之一并返回。这也适用于字符串,例如choose(“ o或Hi。可以使用任何返回下,如果点¯x小于下部,上部如果点¯x大于上,否则返回点¯xx转换为浮点数(小数)x是文本,则在数字之后允许使用非数字float(“3.1xx”)3.1float(“xx3.1”)0。floattextx转换为整数(整数)x是文本,则在数字之后允许使用非数字字int(“33xx”)33int(“xx33”)0。0,2.5,3.29293,而不是4.使用floor(random(4))只生成整数0,1,2,3abab生成包含RGB“YourscoreSystem英文版Thissectionoutlinestheexpressionsinthebuilt-inSystemobjectinConstruct2.Manyarecommonmathematicaloperators,andtheycanbelistedwithdescriptionsintheExpressionspanel,buttheyareincludedhereforThissectiondoesnotlisttheoperatorsorsyntaxthatcanbeusedinexpressions-justtheexpressionsspecifictotheSystemobject.FormoregeneralinformationonhowtouseexpressionsinConstruct2,seeExpressions.DisGettheoriginalvaluesoftheWindowsizeprojectGetthesizeofthecanvasbeingdisyedindevicepixels.Notethisisnotthesameastheviewport;seetheViewportLeft/Top/Right/Bottomexpressions.SeealsoSupportingmultiplescreenInexpressionswherealayerisrequired,eitheritsname(asastring)orindex(asanumber,zero-based)canbeentered.CanvasToLayerX(layer,x,y)CanvasToLayerY(layer,x,Calculatethelayoutco-ordinatesunderneathapositionincanvasco-ordinatesforagivenlayer.LayerToCanvasX(layer,x,y)LayerToCanvasY(layer,x,Calculatethecanvasco-ordinatesaboveapositioninlayoutco-ordinatesforagivenGettheangle,indegrees,ofaGetthezero-basedindexofalayerfromitsGettheopacity(orsemitransparency)ofalayer,from0(transparent)to100GetthecurrentparallaxXandYcomponentsofaGetthecurrentscaleofthelayer,notincludingtheoveralllayoutGetthecurrentscalerateofthelayer,whichdefineshowquicklyitscales(ifatReturntheviewportboundariesinlayoutco-ordinatesofagivenlayer.Notalllayershavethesameviewportiftheyareparallaxed,scaledorrotatedseparay.ContainstheresultingimagefromaSnapshotcanvasactionafterOncanvassnapshothasrun.(NotethisexpressionisnotavailableimmediayaftertheSnapshotcanvasaction-youcanonlyuseitafterOncanvassnapshottriggers.)TheexpressionreturnsadataURIoftheimagefile.ThiscanbeloadedintoaSpriteorTiledBackgroundobjectviaLoadimagefromURL,senttoaserverorstoredlocally,oropenedwiththeBrowserobjectinanewtabtosavetodisk.Gettheangle,indegrees,ofthecurrentlayout.Thisdoesnotincludetherotationofindividuallayers.GetthecurrentscaleoftheentirelayoutsetbytheSetlayoutscaleaction.Thisdoesnotincludethescalingofindividuallayers.GetthesizeofthecurrentlayoutinGetthenameofthecurrentGetthecurrentpositiontheviewiscenteredTheseexpressionsaresimplyordinarymathfunctionslikeyoufindoncalculators.However,notethatallfunctionsusinganangletakeitindegrees,notradians.Anglesstartwith0degreesfacingrightandincrementclockwise.sin(x),cos(x),tan(x),asin(x),acos(x),atan(x)Trigonometricfunctionsusinganglesindegrees.abs(x)Absolutevalueofxe.g.abs(-5)=angle(x1,y1,x2,y2)Calculateanglebetweentwoanglelerp(a,b,x)Linearlyinterpolatetheangleatobbyx.Unlikethestandardlerp,thistakesintoaccountthecyclicalnatureofangles.anglediff(a1,a2)Returnthesmallestdifferencebetweentwoanglesanglerotate(start,end,step)Rotateanglestarttowardsendbytheanglestep,allindegrees.Ifstartislessthanstepdegreesawayfromend,itreturnsend.ceil(x)Roundupxe.g.ceil(5.1)=cosp(a,b,x)Cosineinterpolationofatobbyx.Calculates(a+b+(a-b)*cos(x*180°))/2.cubic(a,b,c,d,x)Cubicinterpolationthrougha,b,canddbyx.Calculateslerp(qarp(a,b,c,x),qarp(b,c,d,x),x).distance(x1,y1,x2,y2)Calculatedistancebetweentwoexp(x)Calculatefloor(x)Rounddownxe.g.floor(5.9)=infinityAfloatingpointnumbervaluerepresentinglerp(a,b,x)Linearinterpolationofatobbyx.Calculatesa+x*(b-unlerp(a,b,y)Reverselinearinterpolation:iflerp(a,b,x)=y,thenunlerp(a,b,y)=x.Calculates(y-a)/(b-a).ln(x)Logtobaseeoflog10(x)Logtobase10ofmax(a,b[,c...]),min(a,b[,c...])Calculateumorminimumofthegivennumbers.Anynumberofparameterscanbeusedaslongasthereareatleasttwo.piThemathematicalconstantpiqarp(a,b,c,x)Quadraticinterpolationthrougha,bandcbyx.Calculateslerp(lerp(a,b,x),lerp(b,c,x),x).round(x)Roundxtothenearestwholenumbere.g.round(5.6)=sqrt(x)Calculatesquarerootofxe.g.sqrt(25)=getbit(x,Getthenthbitofxrepresentedasa32-bitinteger.Forexamplegetbit(7,0)willgettheleastsignificantbitofthenumber7whenrepresentedasa32-bitinteger.Returnseither0or1.setbit(x,n,Setthenthbitofxrepresentedasa32-bitintegertob(either0or1).Theresulting32-bitintegerisreturned.togglebit(x,Togglethenthbitofxrepresentedasa32-bitinteger.Ifthatbitis0,itissetto1;ifitis1,itissetto0.Theresulting32-bitintegerisreturned.Save&InOnsavecompleteorOnloadcomplete,returnsastringofJSONdatarepresentingthesavegamedata.ThiscanlaterbeloadedusingtheLoadfromJSONaction.FormoreinformationseeHowtomakesavegames.Returnstheestimatedtotalmemoryusage,inmegabytes,ofallthecurrently-loadedimages.OnlysupportedintheWebGLrenderer;ifcanvas2Drenderingisinuse,theexpressionalwaysreturns0.Noteimagememoryissometimesalsoreferredtoas"VRAM",butthisisnotstrictlycorrectsincenotalldeviceshave-specificmemory.Alsorememberthisexpressiondoesnotincludethememoryuseofsounds,code,orothernon-imageresources.Returnthecurrentloadprogressonaloaderlayout,orthecurrentupdateprogresswhiletheBrowserobject'sIsdownloadingupdateconditionistrue.Theprogressisreturnedasanumberfrom0to1,e.g.0.5forhalfcomplete.Formoreinformation,seethetutorialshowtomakeacustomloadingscreenandofflinegamesinConstructGettheindex(numberofrepeatssofar)inanycurrentlyrunningGettheindex(numberofrepeatssofar)oftheloopwiththegivenname.Usefulforgettingindicesinnestedloops.ThetotalnumberofobjectscurrentlyReturnthenameoftheprojectasitappearsinProjectReturntheversionenteredintoProjectProperties.Notethatthisisalwaysreturnedasastring,notanumber.Thenameoftherendererusedtodrawthegame,currentlyeithercanvas2dorwebgl.SeeTechnologyformoreinformationoncanvasrenderers.Thenameofthegraphicshardwareinusetodrawthegame,suchasGeGTX660"or"Adreno330".ThisisonlyavailableinWebGLmodeincertainbrowsersandtforms;unsupportedbrowsers/systemswillreturn"(unavailable)".Projectsshouldnotrelyonthisstringhavinganyexactcontents,butitcanbeusefultodiagnosewhichGPUisinuseindual-GPUsystems,ortolookfor andapplydefaultgraphicssettingsbasedonthetypeofhardware.find(src,text)findCase(src,text)Findthefirstindexwithinsrcthattextoccurs,elsereturns-1.findiscase-insensitive,andfindCaseiscase-sensitive.left(text,ReturnthefirstcountcharactersofReturnthenumberofcharactersinConvertthegiventexttoallmid(text,index,ReturnthecountcharactersstartingfromindexinAstringcontainingalinebreak.Usetoinsertlinebreaksintostrings,e.g." o"&newline&"World"RegexMatchAt(String,Regex,Flags,ProcesstheregularexpressionRegexonStringwithFlags,andinthelistofresults,returntheentryatIndex.ProcesstheregularexpressionRegexonStringwithFlags,andreturnthenumberofentriesinthelistofresults.RegexRece(String,Regex,Flags,ReInStringsubstitutematchesfortheregularexpressionRegex(withFlags)withthestringRece.Therecementstringcancontainthefollowingspecialcharacters:$$(insertsa$),$&(insertsthematchedsubstring),$`(insertstheportionofthestringthatprecedesthematchedsubstring),or$'(insertstheportionofthestringthatfollowsthematchedsubstring).RegexSearch(String,Regex,ReturntheindexofthefirstcharacterinStringwhereamatchforRegexwithFlagscouldbefound.rece(src,find,Findalloccurrencesoffindinsrcandrecethemwithright(text,Returnthelastcountcharactersoftokenat(src,index,ReturntheNthtokenfromsrc,splittingthestringbyseparator.Forexample,tokenat("apples|oranges|bananas",1,"|")returnsoranges.tokencount(src,Counthowmanytokensoccurinsrcusingseparator.Forexample,tokencount("apples|oranges|bananas","|")returns3.Returnsrcwithallwhitespace(spaces,tabsetc.)removedfromthebeginningandendofthestring.ConvertthegiventexttoallConverttoandfromastringinaformatsuitableforincludinginaURLorPOSTPadnumberouttoacertainnumberofdigitsbyaddingzeroesinfrontofthenumber,thenreturningtheresultasastring.Forexample,zeropad(45,5)returnsthestringThepercentageofthelastsecondthatwasspentintheapplicationlogic.Thisisforadvanceduserstomakeperformancemeasurements.Noteonhardware-accelerateddevicestherenderinghappensontheseparateGPUandthereforethismeasurementcannotlyouanythingabouthowfastorslowtherenderingis;forthatfpsisabettermeasure.Alsonotethismeasurementisbasedontimerssoshouldbetreatedasanapproximation,anditonlymeasuresthemainJavascriptthreadtime.Delta-timeinseconds.SeeDelta-timeandframerateThecurrentframespersecond(FPS)rate,whichishowmanytimesthescreenisbeingdrawneverysecond.Mostcomputersrunat60fpsiftheyarefastenough.ThenumberofticksthathaverunsincethegameThenumberofsecondssincethegamestarted,takingintoaccountthetimeThecurrenttimeThenumberofsecondssincethegamestarted,nottakingintoaccountthetimescale(i.e.thereal-worldt

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论