跟随者(Follower)
跟随者跟随宿主移动而移动,具有依附的功能,通常用于设备面板,如端口依附在板卡上。
Follower常用的方法如下:
//设置宿主
get/setHost: function(host)
//是否依附在某个节点上
isHostOn: function(node)
//是否是相互依附关系
isLoopedHostOn: function(node)
创建跟随者元素:
var Follower1 = new twaver.Follower({
name: 'Follower1', location: {
x: 300, y: 300 } });
跟随者–》跟随其他节点设置
var node1 = new twaver.Node({
name: 'node1', location: {
x: 100, y: 100 } });
box.add(node1)
var node2 = new twaver.Node({
name: 'node2', location: {
x: 300, y: 600 } });
box.add(node2)
var Follower1 = new twaver.Follower({
name: 'Follower1', location: {
x: 300, y: 300 } });
var Follower2 = new twaver.Follower({
name: 'Follower2', location: {
x: 400, y: 400 } });
box.add(Follower1);
box.add(Follower2);
Follower1.setHost(node1);
Follower2.setHost(node2);
跟随者1跟随node1;
跟随者2跟随node2;
学习参考:TWaver Documents