系統(tǒng)表達式用法級初步漢化版_第1頁
系統(tǒng)表達式用法級初步漢化版_第2頁
系統(tǒng)表達式用法級初步漢化版_第3頁
系統(tǒng)表達式用法級初步漢化版_第4頁
系統(tǒng)表達式用法級初步漢化版_第5頁
已閱讀5頁,還剩13頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

歡迎加 1gbC2資C2比如你想知道精靈A到精靈B之間的距離你該怎么辦,需要用到系統(tǒng)表達式里的distance(x1,y1,x2,y2)函數(shù)x1,y1表示A原點坐標x2,y2表示精靈B標在需要填寫表達式的地方按下圖寫入表達式好了現(xiàn)在把c2系統(tǒng)系統(tǒng)表達本節(jié)概述了構(gòu)造2中的內(nèi)置System對象中的表達式。許多是常見的數(shù)算符,它們可以與“表達式”面板中的描述一起列出,但是這里包括它們是為了完整性。-System對象的表達式。有關(guān)如何在構(gòu)造2中使用表達式的一般信息,請參閱表達式。顯Windowsize;/TopRightBottom表達式。參見支持多種屏幕尺寸c2里指的對象是獲取圖層XYc2里指的對象是畫布操作后立即使用-您只能在“在畫布快照觸發(fā)器之后使用”。)表達式返回圖像文件的數(shù)據(jù)URI。這可以通過從URL加載圖像,發(fā)送到服務(wù)器或本地,或通過新的選SpriteTiledBackground對象。獲取通過設(shè)置布局縮放操作設(shè)置的整個布局的當前縮放。這不包括單個圖層的縮c2里指的角度的函數(shù)以度0度開始朝右,順時針增加。ABS(x)的x的絕對值A(chǔ)BS(-5)=anglelerp(A,B,x)的線性內(nèi)插角度一b由點ˉxlerp不同,這考慮到離結(jié)束小于步距離,則返回結(jié)束。ceil(x)x例如ceil(5.1)6cosp(a,b,x)abx。計算(A+B+(一-二)*COS(X*180°))/2。立方(,,,,)的一個b?和e由點xep(apa,b,c,),r(,cd,x,x)距離(,1,,)x()計算e^xfoo()舍入x例如or59=5fnity表示無窮大的浮點數(shù)值。e(,,)a到bxa+x(-)。une(,b,)反向線性插值:如果lp(,,x=y,則ulr(,,y)=。計算(-a)ba)。()日志到x的ae。o1()x1。(,b,c)(,b,c)圓周率的數(shù)學常數(shù)pi319)qa(,,,)一個b和?由點xepepab,x,lpb,c,x),x)。oun()rndxrn(56=6sqr()計算x例如sr(5=5701。32x的第n位設(shè)置為b(01)3232xn0110.32保存并加在“”“上保存JN使用從JN載操加載。關(guān)息,請如何制作保存游戲。c2里指的對象是()WbL;如果nvaD0“R”,這不是格正確,因為非所有設(shè)都具有存。還要記住個表達不包括存使用,碼其他非圖資源。010.5,一半完成。有關(guān)詳細信息,請參閱教程Construct2中創(chuàng)建自定義加載屏幕和離線游戲。渲染器c2里指的對用來繪制游戲中,無論是當前的渲染器的名稱canvas2d或的。有關(guān)畫布渲染器的信息,請參閱技術(shù)用于繪制游戲的圖形硬件的名稱,例如“NVIDIAGeGTX660”或“Adreno330”。這只在某些瀏覽器和平臺的WebGL模式下可用;不支持的瀏覽器/系統(tǒng)將返回“(不可用)”GPU系GPU,或者查找關(guān)鍵字并根據(jù)硬件類型應(yīng)用默認圖形設(shè)置。c2里指的對象是find(src,left(text,返回第一個計數(shù)的字符文本返回文本中的字符數(shù)mid(text,index,返回計數(shù)啟動字的索引中的文本處理正則表達式RegexonString,并在結(jié)果列表中返回Index處的條目過程中的正則表達式正則表達式的字符串與標志,并返回結(jié)果列表中的條目數(shù)rece(src,find,查找所有出現(xiàn)的發(fā)現(xiàn)在SRC和替換它們代表right(text,返回最后計數(shù)的字符文本tokenat(src,index,從返回的第NSRC,通過拆分字符串分隔符。例如,tokenat(“apples|oranges|bananas”,1,“|”)返回橙子。src中發(fā)生多少個令牌。例如,tokencount(“apples|oranges|bananas”,“|”)3。墊數(shù)出一定數(shù)目的位數(shù)由在數(shù)字前面加上零,那么返回結(jié)果為字符串。(45,5)返回字符串“00045”c2里指的對象是GPU上,因此這種測量不能告訴你任何關(guān)于渲染的速度或速度fps是一個更好的措施。還要注意,這個測量是基于計時器,所以應(yīng)該被當作Javascript線程時間。當前幀每秒(FPS)60fps,c2里指的對choose(a,b[,隨機選擇一個給定的參數(shù)。例如,選擇(1,3,9,20)隨機選擇四個數(shù)字之一并返回。這也適用于字符串,例如choose(“ o或Hi??梢允褂萌魏畏祷叵?,如果點ˉx小于下部,上部如果點ˉx大于上,否則返回點ˉxx轉(zhuǎn)換為浮點數(shù)(小數(shù))x是文本,則在數(shù)字之后允許使用非數(shù)字float(“3.1xx”)3.1float(“xx3.1”)0。floattextx轉(zhuǎn)換為整數(shù)(整數(shù))x是文本,則在數(shù)字之后允許使用非數(shù)字字int(“33xx”)33int(“xx33”)0。0,2.5,3.29293,而不是4.使用floor(random(4))只生成整數(shù)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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論