例子:普通路径的基础用法

local arrow = cc.CmdArrow:create();
arrow:addNormalPath(1, { cc.p(0, 0), cc.p(300, 300) });
arrow:addNormalPath(1, { cc.p(300, 0), cc.p(300, 300) });
arrow:rebuildVertexes();
scene:addChild(arrow);
例子:删除路径

local arrow = cc.CmdArrow:create();
arrow:addNormalPath(1, { cc.p(0, 0), cc.p(300, 300) });
local path = arrow:addNormalPath(1, { cc.p(300, 0), cc.p(300, 300) });
-- 删除路径
arrow:removePath(path:getID());
arrow:rebuildVertexes();
scene:addChild(arrow);
例子:同一组的多条路径合并

local arrow = cc.CmdArrow:create();
arrow:addNormalPath(1, { cc.p(0, 0), cc.p(300, 300) });
arrow:addNormalPath(1, { cc.p(300, 0), cc.p(300, 300) });
arrow:addNormalPath(1, { cc.p(330, 0), cc.p(300, 300) });
arrow:addNormalPath(1, { cc.p(400, 0), cc.p(300, 300) });
arrow:rebuildVertexes();
scene:addChild(arrow);
例子:不同组的路径不合并

local arrow = cc.CmdArrow:create();
arrow:addNormalPath(1, { cc.p(0, 0), cc.p(300, 300) });
arrow:addNormalPath(1, { cc.p(300, 0), cc.p(300, 300) });
arrow:addNormalPath(2, { cc.p(330, 0), cc.p(300, 300) });
arrow:addNormalPath(2, { cc.p(400, 0), cc.p(300, 300) });
arrow:rebuildVertexes();
scene:addChild(arrow);
例子:包围(需要至少2条路径)

local arrow = cc.CmdArrow:create();
arrow:addWrapPath(1, { cc.p(300, 300), cc.p(500, 500) });
arrow:addWrapPath(1, { cc.p(300, 600), cc.p(500, 500) });
arrow:addWrapPath(1, { cc.p(600, 300), cc.p(500, 500) });
arrow:rebuildVertexes();
scene:addChild(arrow);
例子

- ADE攻打C:合并指挥线
- A攻打B:单独一条指挥线
发现跟攻打目标存在关系
local c = 1;
arrow:addNormalPath(c, {A, C });
arrow:addNormalPath(c, {D, C });
arrow:addNormalPath(c, {E, C });
local b = 2;
arrow:addNormalPath(b, {A, B });
网友评论