找回密码
 点一下
楼主: hke

怎么判断单位离开或进入圆形的一个区域呢

[复制链接]
发表于 2008-6-11 23:46:50 | 显示全部楼层
按我的想法,改了下

[codes=jass]function RegionAddCircle takes region whichRegion, real x, real y, real radius returns nothing
      local real delta = radius / 32
      local real r = 16
      local real w = 0
      local rect t = Rect(0, 0, 0, 0)
      if delta < r then
            set r = delta
      else
            set delta = r
      endif
      loop
            exitwhen r > radius
            set w = SquareRoot(radius * radius - r * r)
            call SetRect(t, x - r, y - w, x + r, y + w)
            call RegionAddRect(whichRegion, t)
            set r = r + delta
      endloop
      call RemoveRect(t)
      set t = null
endfunction[/codes]

发现进入区域事件触发时单位坐标貌似在区域外,矩形区域也是如此………………

另外,朱朱大人的代码里
[codes=jass]call SetRect(t, x - w, y + r - 16.00, x + w, y + r + 16.00)
call RegionAddRect(whichRegion, t)
call SetRect(t, x - w, y - r - 16.00, x + w, y - r + 16.00)
call RegionAddRect(whichRegion, t)[/codes]
不是很明白,我改成了
[codes=jass]call SetRect(t, x - w, y - r , x + w, y + r)
call RegionAddRect(whichRegion, t)[/codes]
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 点一下

本版积分规则

Archiver|移动端|小黑屋|地精研究院

GMT+8, 2024-7-20 18:17 , Processed in 0.063547 second(s), 18 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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