动态组件生成器扩展
UPDATE HISTORY:
V8.1:
fix spelling mistake and missing property in helper block.
V8 :
Helper blocks added for component socket and property socket,
now NO NEED to type the component name or proerty name, just select from the dropdown list:
ONLY USE THIS IN NEW PROJECT, THIS MAY DAMAGE YOUR PROJECT USING PREVIOUS VERSION.
v7.1
bug fixed for "can not remove Sprite / Ball from Canvas"
v7:
Add OnClick and OffClick methods
OnClick will bind a click event to a component like label, button.
This one have high priority than native event.
OffClick will unbind the click event.
v7:
如果你想在运行时替换模板中的属性值,替换成{1},{2},{3}...这样。
然后在values中添加需要替换的真实的属性值。
===================================
WxBit已经集成了动态生成组件的功能,但是MIT官网并没有这个功能。
本扩展就是为了这部分同学使用动态组件功能开发
所有功能块
创建组件
component:要生成的组件的类型,可以是文本,比如Button,就是这个组件的(英文)类名,或者比如这种块。
in: 新生成的组件的父容器,这里必须是这种块或变量,不能再是文本型。
移除组件
设置属性和读取属性
property:
可以是以下3种情侣:
可以是组件的自带的属性,必须是英文;
可以是“index”,用来设置组件的排列顺序;
可以是其他自定义的属性,比如id,parent之类的任意文本,中英皆可。
获取子组件列表和父组件
只适用于获取动态生成的子组件或他的父组件
使用模板创建多个组件
模板(Template)是一个json字符串。
可以根据以下格式手动编写,或者在MIT服务器上的设计界面拖入需要的界面,根据需要设置相应的组件属性。选中最外层组件,键盘上按下Ctrl + C,然后在任何文本编辑器里面按键盘上的Ctrl+V,就可以得到模板了
以下模板中的$Name,$Version,Uuid,$blocks几个键是从mit自动转换来的,模板中并不需要。你可以把它们删掉,也可以保留,扩展会自动忽略他们。$Components 和$Type是必须保留的。
如果你想在运行时替换模板中的属性值,可以像下图这样,替换成\1, \2,\3...这样。
DOWNLOAD HERE:
cn.kevinkun.CompCreator-v6.2.aix.zip
cn.kevinkun.CompCreator-v7.aix.zip
cn.kevinkun.CompCreator-v7.1.aix.zip
cn.kevinkun.CompCreator-V8.aix.zip
cn.kevinkun.CompCreator-v8.1.aix.zip
Credit:
This extension is inspired on the fabulous work of Yusuf Cihan: https://github.com/ysfchn/DynamicComponents-AI2