- override
Called after update is complete, if the constraint has been added to a
Node
. Override this method to modify the node's property according to
the constraint.
Source
@override void constrain(Node node, double dt) { Point targetPosition; if (targetNode.spriteBox != node.spriteBox || node.parent == null) { // The target node is in another sprite box or has been removed return; } if (targetNode.parent == node.parent) { targetPosition = targetNode.position; } else { targetPosition = node.parent.convertPointFromNode(Point.origin, targetNode); } if (offset != null) targetPosition += offset; if (dampening == null) node.position = targetPosition; else node.position = GameMath.filterPoint(node.position, targetPosition, dampening); }