mirror of
https://github.com/rm-code/Graphoon.git
synced 2024-11-16 18:24:22 +00:00
Add setter for customizing a node's mass
This commit is contained in:
parent
86788b748d
commit
1681c649fb
@ -23,6 +23,7 @@ function Node.new( id, x, y, anchor, ... )
|
||||
local px, py = x or 0, y or 0;
|
||||
local ax, ay = 0, 0;
|
||||
local vx, vy = 0, 0;
|
||||
local mass = DEFAULT_MASS;
|
||||
|
||||
---
|
||||
-- Clamps a value to a certain range.
|
||||
@ -69,7 +70,7 @@ function Node.new( id, x, y, anchor, ... )
|
||||
dx = dx / distance;
|
||||
dy = dy / distance;
|
||||
|
||||
local strength = FORCE_CHARGE * (DEFAULT_MASS / (distance * distance));
|
||||
local strength = FORCE_CHARGE * ( mass / ( distance * distance ));
|
||||
applyForce(dx * strength, dy * strength);
|
||||
end
|
||||
|
||||
@ -114,6 +115,10 @@ function Node.new( id, x, y, anchor, ... )
|
||||
return anchor;
|
||||
end
|
||||
|
||||
function self:setMass( nmass )
|
||||
mass = nmass;
|
||||
end
|
||||
|
||||
return self;
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user