精灵方向移动问题[math.floor]

local xd = math.cos(math.rad(self._direction));--self._direction方向角度
local yd = math.sin(math.rad(self._direction));

--math.floor 罪魁祸首啊
-- local posX = math.floor(self:getPositionX() + self._initData.cfg.speed * delay_ * xd);
-- local posY = math.floor(self:getPositionY() + self._initData.cfg.speed * delay_ * yd);

local posX = self:getPositionX() + self._initData.cfg.speed * delay_ * xd;
local posY = self:getPositionY() + self._initData.cfg.speed * delay_ * yd;

 

如果此刻speed为100,self._direction为30度,那就是X轴横向移动了,因为按照这个速度60帧的帧率每次X轴移动都大于1,Y轴移动小于1所以Y永远都没变。

改变其他值有可能不动,有可能纵向移动。自个琢磨。。。

 

posted @ 2017-01-05 11:32  黔王  阅读(135)  评论(0编辑  收藏  举报