Browse Source

修正aoi根据坐标获取格子ID x,y写错问题

master
aceld 5 years ago
parent
commit
17336c7996
  1. 2
      zinx_app_demo/mmo_game/core/aoi.go

2
zinx_app_demo/mmo_game/core/aoi.go

@ -129,7 +129,7 @@ func (m *AOIManager) GetSurroundGridsByGid(gID int) (grids []*Grid) {
//通过横纵坐标获取对应的格子ID //通过横纵坐标获取对应的格子ID
func (m *AOIManager) GetGidByPos(x, y float32) int { func (m *AOIManager) GetGidByPos(x, y float32) int {
gx := (int(x) - m.MinX) / m.gridWidth() gx := (int(x) - m.MinX) / m.gridWidth()
gy := (int(x) - m.MinY) / m.gridLength()
gy := (int(y) - m.MinY) / m.gridLength()
return gy*m.CntsX + gx return gy*m.CntsX + gx
} }

Loading…
Cancel
Save