mirror of
https://github.com/rm-code/Graphoon.git
synced 2024-11-16 18:24:22 +00:00
Add two callback functions to the parameter list of the update function
These functions will be called on each and every node and edge in the graph and allow the user to extend the graphs behavior between frames.
This commit is contained in:
parent
8146caa558
commit
b30389bf8a
@ -115,11 +115,14 @@ function Graph.new()
|
||||
---
|
||||
-- Updates the graph.
|
||||
-- @param dt - The delta time between frames.
|
||||
-- @param nodeCallback - A callback called on every node.
|
||||
-- @param edgeCallback - A callback called on every edge.
|
||||
--
|
||||
function self:update( dt )
|
||||
function self:update( dt, nodeCallback, edgeCallback )
|
||||
for _, edge in pairs( edges ) do
|
||||
edge.origin:attractTo( edge.target );
|
||||
edge.target:attractTo( edge.origin );
|
||||
edgeCallback( edge );
|
||||
end
|
||||
|
||||
resetBoundaries();
|
||||
@ -133,6 +136,7 @@ function Graph.new()
|
||||
end
|
||||
nodeA:move( dt );
|
||||
end
|
||||
nodeCallback( nodeA );
|
||||
|
||||
minX, maxX, minY, maxY = updateBoundaries( minX, maxX, minY, maxY, nodeA:getPosition() );
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user