45 degree angle map coordinate calculation and level calculation

//The distance between 2 squares x

xdis = 38

//The distance between 2 squares y

ydis = -19

 

//Pass in XY subscript to get coordinates 45 degree angle map    

    getPositonByXY(_x :number, _y : number){

        return cc.v2(_x * this.xdis + _y* this.xdis, _y * this.ydis - _x *  this.ydis)

    }

 

    // Incoming XY subscript to get the level Y is the bigger the level is the higher the level is, the smaller the X is, the higher the level is

    getZorderByXY(_x :number, _y : number){

        return _y*100 + 100 -_x;

    }

 

Guess you like

Origin blog.csdn.net/qq_17148595/article/details/115002132