- 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) { Offset offset; if (targetNode.spriteBox != node.spriteBox) { // The target node is in another sprite box or has been removed return; } if (targetNode.parent == node.parent) { offset = targetNode.position - node.position; } else { offset = node.convertPointToBoxSpace(Point.origin) - targetNode.convertPointToBoxSpace(Point.origin); } double target = degrees(GameMath.atan2(offset.dy, offset.dx)) + baseRotation; node.rotation = _dampenRotation(node.rotation, target, dampening); }