mirror of
https://github.com/rm-code/Graphoon.git
synced 2024-11-16 18:24:22 +00:00
Add parameter for specifying node names
This commit is contained in:
parent
9723b80c98
commit
b5649d3fd4
@ -72,9 +72,9 @@ function Graph.new()
|
||||
-- @param anchor - Wether the node should be locked in place or not (optional).
|
||||
-- @param ... - Additional parameters (useful when a custom Node class is used).
|
||||
--
|
||||
function self:addNode( id, x, y, anchor, ... )
|
||||
function self:addNode( id, name, x, y, anchor, ... )
|
||||
assert( not nodes[id], "Node IDs must be unique." );
|
||||
nodes[id] = Node.new( id, x, y, anchor, ... );
|
||||
nodes[id] = Node.new( id, name, x, y, anchor, ... );
|
||||
return nodes[id];
|
||||
end
|
||||
|
||||
|
@ -17,7 +17,7 @@ local DEFAULT_MASS = 3;
|
||||
-- @param y - The y coordinate the Node should be spawned at (optional).
|
||||
-- @param anchor - Wether the node should be locked in place or not (optional).
|
||||
--
|
||||
function Node.new( id, x, y, anchor )
|
||||
function Node.new( id, name, x, y, anchor )
|
||||
local self = {};
|
||||
|
||||
local px, py = x or 0, y or 0;
|
||||
@ -143,6 +143,10 @@ function Node.new( id, x, y, anchor )
|
||||
return mass;
|
||||
end
|
||||
|
||||
function self:getName()
|
||||
return name;
|
||||
end
|
||||
|
||||
return self;
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user