0

我有一个尺寸为 1162 x 16 的图像,我想在触摸“移动相位”事件时旋转它,问题是当图像旋转时它会被打乱“像素化”,尽管它没有被缩放,我尝试了一个图像尺寸为 128 x 128 但图像没有像素化,可能是由于图像尺寸太大!

旋转会影响图像结构吗???有人知道为什么会这样吗???

或者,如果有人有解决方法,请您帮我解决一下。

这是正方形后的更新代码:

local bck = display.newRect (0,0,display.contentWidth,display.contentHeight)
bck.x = display.contentWidth * 0.5
bck.y = display.contentHeight * 0.5
bck:setFillColor (255,255,255)

local img = display.newImageRect ("laser1.png",1170,1170)
img.x = display.contentWidth * 0.5
img.y = display.contentHeight * 0.5


local  function getRotation(PointX1,PointY1,PointX2,PointY2)
  --display.getCurrentStage():setFocus ( Bug )
  local atan2 = math.atan2
  local pi = 3.14159265358

  local deltax = PointX2 - PointX1
  local deltay = PointY2 - PointY1

  local currentAngle = ((atan2(deltay,deltax) )* 180.0) / pi
  local rotationDigree = currentAngle - img.previousAngle;

  img.previousAngle  = currentAngle

  return rotationDigree;
 end

local function handleTouch ( event )
 img.previousAngle = 1
 if( event.phase == "moved" ) then
    img.rotation = getRotation ( img.x , img.y , event.x , event.y )
 end
end


Runtime:addEventListener ("touch",handleTouch)       
4

1 回答 1

0

你的图像不是正方形的。这意味着当您旋转 90 度(例如)时,您正试图将 16 x 1162 的图像放入 1162 x 16 的空间中。

这意味着图像在一个维度上被挤压并在另一个维度上被拉伸。

您需要将源图像和目标图像都设置为 1162 x 1162 添加边框,透明或原始图像中没有的某些已知颜色,以便在旋转完成后将其移除。

128 x 128 的测试图像有效,因为它是正方形的。

于 2011-10-24T09:41:41.680 回答