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 anchor - Wether the node should be locked in place or not (optional).
|
||||||
-- @param ... - Additional parameters (useful when a custom Node class is used).
|
-- @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." );
|
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];
|
return nodes[id];
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ local DEFAULT_MASS = 3;
|
|||||||
-- @param y - The y coordinate the Node should be spawned at (optional).
|
-- @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).
|
-- @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 self = {};
|
||||||
|
|
||||||
local px, py = x or 0, y or 0;
|
local px, py = x or 0, y or 0;
|
||||||
@ -143,6 +143,10 @@ function Node.new( id, x, y, anchor )
|
|||||||
return mass;
|
return mass;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function self:getName()
|
||||||
|
return name;
|
||||||
|
end
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user