Hi. I have started with corona for the first time today. It is also my first time in lua but I have a programming background so the conversion to lua is, so far, not an issue. In the game i am trying to make, i have a background which covers the entirety of the screen and a character near the bottom. I am trying to make it so that swiping to the right will rotate the character clockwise and rotating left counter-clockwise. This is my code so far:
local background = display.newImageRect(“bg.png”, display.contentWidth, display.contentHeight)
background.x = display.contentCenterX
background.y = display.contentCenterY
local character = display.newImageRect(“char.png”, display.contentWidth/3, display.contentHeight/2)
character.x = display.contentCenterX
character.y = display.contentHeight - 25
character.anchorY = 1
character.rotation = 0
function background:touch( event )
local markX = 0
if event.phase == “began” then
markX = event.x
elseif event.phase == “moved” then
character.rotation = character.rotation-(markX-event.x)/1000
markX = event.x
end
return true
end
background:addEventListener( “touch”, background )
The issue I am having is as follows: swipes to the right or left will always have the character rotating clockwise. Another issue I’m having is that the background, although set to the width and height of the screen, still has black space above and below it. I’ve noticed moving my character down will allow him to be seen in the black area so I take it that the black area should have my background show up aswell. Any help would be much appreciated. Thankyou.