欢迎来到天天文库
浏览记录
ID:36035460
大小:165.68 KB
页数:7页
时间:2019-04-29
《scratch 扩展》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、CreatingScratch2.0Extensions进行Scratch2.0扩展JohnMaloney约翰·马拉纳MITMediaLaboratory麻省多媒体实验室September,20132013年9月NOTE1:Thisspecificationsupersedesallearlierdrafts.注解1:这份说明书取代了所有早期版本NOTE2:Thisspecificationisstillpreliminaryandmaychange.注解2:这份说明书仍然是初稿并且会被修改Introduction介绍Scratch2.0ca
2、nbeextendedtocontrolexternaldevices(e.g.roboticskits,musicalinstruments)andtoaccessdatafromexternalsensorhardware(e.g.sensorboards).AScratch2.0extensionextendsScratchwithacollectionofcommandandreporterblocksthatcanbeusedtointeractwithaparticulardevice.Whenanextensionisenabl
3、ed,itsblocksappearinthe"MoreBlocks"palette.Scratch2.0可以被扩展到外部设备(例如:机器配件,乐器),也可以获取来自外部硬件传感器(例如:传感器板)的数据。Scratch2.0扩展模块通过命令收集和记录组块,使Scratch可以被用于和特殊设备进行互动。当扩展启动时,它的扩展组块在”MoreBlocks”控制面板显示。Duetobrowsersecurityrestrictions,Scratch2.0cannotinteractwithhardwaredevicesdirectly.Inst
4、ead,hardwareextensionscomewithahelperapp,aseparateapplicationthattheusermustinstallandrunontheircomputer.ScratchcommunicateswiththehelperappviaHTTPrequests,andthehelperapptalkstothehardware.Inthefuture,someextensionsmaypackagetheirhelperappsasbrowserplugins,butthatmechanism
5、isnotdescribedhere.由于浏览器安全限制,Scratch2.0不能和硬件设备直接互动。而是通过一个用户必须安装和运行在电脑上的独立应用程序实现对硬件的扩展。Scratch通过HTTP请求与帮助程序交流,而帮助程序则和硬件通信。未来,一些拓展会把帮助程序打包成浏览器插件,但原理不在此描述。ThisdocumentisaimedatScratch2.0extensiondevelopers.Itdescribestheextensiondescriptionfileformat,theprotocolusedtocommunica
6、tebetweenScratchextensionhelperapps,andtheextensiondevelopmentprocess.这个文档主要为Scratch2.0扩展研发者服务。这里描述了扩展开发过程的文件格式,曾经用于连接Scratch扩展辅助程序和扩展开发过程的协议。Extensiondescriptionfile扩展描述文件AnextensiondescriptionfileisatextfileinJSONformat(www.json.org)thatdescribestheextension.Byconvention,
7、aScratch2.0extensionfileendsin.s2e.TheJSONobjectintheextensiondescriptionfileincludestheextension'sname,theTCP/IPportNumberusedtocommunicatewiththeextensionshelperapp,andalistofScratchblockspecifications.Hereisanexample:一个扩展描述文件是一个JSON格式的文本文件,用以描述扩展。通常,Scratch2.0扩展文件是以“.s2e
8、”作为文件扩展名的。在扩展描述文件中,一个JSON实例包含扩展的名字,用来和辅助应用程序通信的TCP/IP端口号码和一组组件清单。下面是一个例子。{"extensi
此文档下载收益归作者所有