Twaver-HTML5 Basic Learning (15) Follower (Follower)

Follower

The follower moves with the host and has the function of attachment. It is usually used in the device panel, such as the port attached to the board.

Follower commonly used methods are as follows:

//设置宿主
get/setHost: function(host)
//是否依附在某个节点上
isHostOn: function(node)
//是否是相互依附关系
isLoopedHostOn: function(node)

Create a follower element:

 var Follower1 = new twaver.Follower({
    
     name: 'Follower1', location: {
    
     x: 300, y: 300 } });

Follower - "Follow other node settings

 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);

Follower 1 follows node1;
Follower 2 follows node2;
insert image description here

Learning reference: TWaver Documents

Guess you like

Origin blog.csdn.net/qq_43291759/article/details/124329632