设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 89|回复: 0

[转载发布] SDJB_DrawLinesBetween

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    2026-7-12 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    7522

    主题

    864

    回帖

    3万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    29051
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    37467

    灌水之王

    发表于 2 小时前 | 显示全部楼层 |阅读模式
    PluginName: SDJB_DrawLinesBetween
    Author: ShadowDragon





    Cool feature, draw progress line (0-1), for skill tree in one way.




    CTBolt created a nice plugin "CreateLinesBetween", but has some issues
    and bugs, and was for MZ only.

    As I re-create it from scratch and some logic from his, I improved performance
    and optimized it to make it work for MV and MZ.

    I also added some features, see spoiler how to use.

    Spoiler: How to use
                    Code:       
    1. Introduction
    2. ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞
    3. Create Lines between player to event, follower to event, event to event
    4. or map coordinates (x,y) in tiles or pixels.
    5. How to Use
    6. ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞
    7. There are some scriptcalls you can use to make it clean, easy and
    8. best of all, user-friendly and efficient.
    9. There are 3 ways to set it up!
    10. $gameScreen.setLine(connect, options)
    11. connect:
    12.    => There are 2 ways for connect the sources
    13.    1) Characters connect is using an array [A, B]
    14.       
    15.         0 = player
    16.       < 0 = followers
    17.       > 0 = event ID
    18. Example:
    19.    $gameScreen.setLine([0, 3])    //=> player ↔ event 3
    20.    $gameScreen.setLine([-2, 7])   //=> follower 2 ↔ event 7
    21.    $gameScreen.setLine([2, 5])    //=> event 2 ↔ event 5
    22. You can use options to customize the line:
    23.    pixel, zIndex, width, color, progress, speed, alpha and pulse.
    24. Example:
    25.    $gameScreen.setLine([2,5], {width: 2, color:0x00ff00, alpha: 1});
    26. zIndex:
    27.     Sets the line priority, higher values appear above lower values.
    28.     Default is 0.
    29. width:
    30.     The thickness of the line (default is 2)
    31. mode:
    32.     Determines how the line is animated.
    33.        "progress" = line is drawn over time.
    34.            The initial progress of the line (0 → 1). Default is 1 (instant).
    35.            Can be used to start the line partially drawn.
    36.        "pulse"    = line continuously grows and shrinks in width.
    37.            Enables a pulsing width animation.
    38.            The value is the maximum additional width applied during the pulse cycle.
    39.            width: 2, pulse: 2  //=> 2px ↔ 4px
    40.            width: 2, pulse: 3  //=> 2px ↔ 5px
    41.     Default is "none".
    42. speed:
    43.     Controls the animation speed.
    44.        mode: "progress"
    45.            Number of frames required to draw the line completely.
    46.        mode: "pulse"
    47.            Number of frames required to expand from the base width
    48.            to the maximum pulse width.
    49. color:
    50.     The color of the line in hex: "#FF0000" or 0xFF0000, as both works
    51.     The default color is white (0xFFFFFF)
    52. alpha:
    53.     The alpha color, which by default is 1
    54.    2) Coordinates connects is using an object array [{x:n, y:n},{x:n, y:n}]
    55.       This can also go in 2 ways, by tiles or by pixels (default false)
    56.       By default, pixels is false, meaning: coordinate by tiles.
    57. Example:
    58.     Start at Map X 4, Y 6 and end at X 10, Y 48:
    59.     $gameScreen.setLine([{x:4,y:6}, {x:10,y:48}])
    60.     Start at Map X 210, Y 30 and end at X 700, Y 300
    61.     $gameScreen.setLine([{x:210,y:30},{x:700,y:300}], {pixel:true});
    62.     pixel:
    63.       true  = pixel coordinates
    64.       false = map tiles
    65.     With all options (optional):
    66.     $gameScreen.setLine([{x:50,y:50},{x:500,y:500}], {
    67.        pixel:true, zIndex:1, width:4, pulse:3, speed:120, color:0x00FF00, alpha:0.7});
    68.    3) Besides connecting character to character, or Map coordinates,
    69.       you could also connect events to map coordinates.
    70. Example:
    71.     $gameScreen.setLine([0, {x:8, y: 10}])    //=> player ↔ Map Coordinates
    72.     $gameScreen.setLine([0, {x:8, y: 10}], {color: "#00FFFF"})
    73. Remove Lines between map coordinates:
    74. Example:
    75.     $gameScreen.removeLineCoords({x:4, y:6})
    76.     This removes all lines, connected to that map coordinate.
    77. Removing Lines between connections is relative easy as well.
    78. Example:
    79.     This require an start point and end point (can be used reversed)
    80.     $gameScreen.removeLinesBetween(disconnect)
    81.     Sample for characters:
    82.     $gameScreen.removeLinesBetween([3,5])
    83.     $gameScreen.removeLinesBetween([5,3]) => same effect as above
    84.     Sample for map coordinates:
    85.     $gameScreen.removeLinesBetween([{x:3,y:5},{x:10,y:20}])
    86.     $gameScreen.removeLinesBetween([{x:10,y:20},{x:3,y:5}])  => same effect as above
    87.     Sample for character and map coordinates:
    88.     $gameScreen.removeLinesBetween([6,{x:10,y:20}])
    89.     $gameScreen.removeLinesBetween([{x:10,y:20},6])  => same effect as above
    90.     If Multple was connected to the same point, remove one line between them.
    91. Removing a Line from one source can break all others.
    92. Example:
    93.     You have a connect A to B, A to C, A to D, D to E
    94.     $gameScreen.removeLine(source)
    95.     Removes ALL lines connected to the source.
    96.     Remaining nodes stay connected to each other.
    97.     Sample:
    98.     $gameScreen.removeLine(2);   
    99.     This removes all lines connected to event 2
    100. To remove all lines, use the following line:
    101.     $gameScreen.removeAllLines();
    102. Pixel Distance
    103. ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞
    104. Check the console log for the pixel distance and use
    105. the following scriptcall:
    106. Example:
    107.    $gameScreen.lineInPixels(sourceA, sourceB, pixels)
    108. souceA / sourceB: check the distance between map coords or characters.
    109.                    (player, followers, events)
    110. pixels (optional): default is false, and only works for map coordinates
    111.                    when using pixels.
    112. To check the map coordinates (tiles) distance in pixels:
    113.    $gameScreen.lineInPixels({x:1, y:4}, {x:5, y:6})
    114. To check the map coordinates in pixels:
    115.    $gameScreen.lineInPixels({x:32, y:128}, {x:64, y:192}, true)
    116. To check the characters distance in pixels (player, followers, events):
    117.    $gameScreen.lineInPixels(3, 12)
    118. In order to use it in a conditional branch to check if its true or false
    119. if map coordinates (tiles) to event id 12 is lower than 96 pixels distance.
    120.    $gameScreen.lineInPixels({x:1, y:4}, 12) < 96
    121. Or if you use map coords in pixels:
    122.    $gameScreen.lineInPixels({x:32, y:128}, 12, true) < 96
    123. Use the console log first to see the actual pixel distance.
    124. This makes creating pixel-based conditions easier and more accurate.
    复制代码


    zIndex and pulse






    === TERMS OF USE ===
    Free for Non-Commercial and Commercial use when credit is given.
    credit one of the following:
    ShadowDragon
    ShadowDragonJB


    === WARNING ===
    YOU ARE NOT ALLOWED TO:
    * MODIFY without permission
    * EXTEND without permission
    * TAKE CODE without permission
    * CLAIM AS YOU MADE IT
    * REDISTRIBUTE but link back to the forum or itch.io
    * SELL this product as standalone.
    * DO NOT REMOVE THE HEADER.


    Download fromitch.io  (require my base plugin (SDJB_Base or SDJB_BaseMZ (minified version))


    本贴来自国际rpgmaker官方论坛作者:ShadowDragon处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/sdjb_drawlinesbetween.182091/

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-7-30 19:33 , Processed in 0.076143 second(s), 57 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表