原理:
旋转前(a,b) 旋转后(a',b') 旋转角度为X
a'=acos(t+X)=a*costcosX-a*sintsinX=acosX-bsinX
b'=bsin(t+X)=b*costsinX+b*sintcosX=asinX+bcosX
p'(acosX - bsinX,bsinX + bsinX) :
------------------------代码
local rectW = self.pic_BeEequal:getSize().width
local rectH = self.pic_BeEequal:getSize().height
精灵默认锚点是0.5 所以中点就是这个X
local rectCentPosY = self.pic_BeEequal:getPos().y
local nTempX ,nTempY =0,0
local deg = (self.pic_BeEequal:getRotation()) * math.pi / 180
-- 还原鼠标点 ,先平移到中点。
nTempX = rectCentPosX + (touches[1]:getLocation().x - rectCentPosX) * math.cos(deg) - (touches[1]:getLocation().y - rectCentPosY) * math.sin(deg)nTempY = rectCentPosY + (touches[1]:getLocation().x - rectCentPosX) * math.sin(deg) + (touches[1]:getLocation().y - rectCentPosY)* math.cos(deg)
-- rect
print("nTempX",nTempX)
print("nTempY",nTempY)
dump(self.rect) -- 旋转之前的矩形
if cc.rectContainsPoint(self.rect,cc.p(nTempX,nTempY)) then
print("............<<<<<<<<<<<<<<")
end