タッチ「移動フェーズ」イベントで回転させたいサイズ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)