Having trouble with a code

So the problem i’m having is that I need to adjust the following code to use only one text object instead of two. I’m completely lost on how to do that. I’m sure there’s an obvious answer to my problem but i’m just not seeing it. Any help or tips would be great.

–Declare two text objects, set one to white and make one not visible 

local portrait = display.newText(“Portrait”, display.contentWidth/2, display.contentHeight/2, native.systemFont, 24) 

local landscape = display.newText(“Landscape”, display.contentWidth/2, display.contentHeight/2, native.systemFont, 24) 

     portrait:setFillColor(1, 1, 1) 

     portrait.alpha = 1 

     landscape:setFillColor(1, 1, 1) 

     landscape.alpha = 0 

local function onOrientationChange (event) 

if (event.type ==“landscapeRight” or event.type == “landscapeLeft”) then 

     local newAngle = landscape.rotation - event.delta 

     transition.to( landscape, {time= 150, rotation = newAngle}) 

     transition.to( portrait, {rotation = newAngle}) 

     portrait.alpha = 0 

     landscape.alpha = 1 

else 

     local newAngle = portrait.rotation - event.delta 

     transition.to( portrait, {time= 150, rotation = newAngle}) 

     transition.to( landscape, {rotation = newAngle}) 

     portrait.alpha = 1 

     landscape.alpha = 0

  end 

end 

Runtime:addEventListener( “orientation”, onOrientationChange )

If I get you correctly you just want one message and alter the text depending on orientation?

local message = display.newText("Portrait", display.contentWidth/2, display.contentHeight/2, native.systemFont, 24) local function onOrientationChange (event) if (event.type =="landscapeRight" or event.type == "landscapeLeft") then local newAngle = message.rotation - event.delta transition.to( message, {time= 150, rotation = newAngle}) message.text="Landscape" else local newAngle = message.rotation - event.delta transition.to( message, {time= 150, rotation = newAngle}) message.text="Portrait" end end Runtime:addEventListener( "orientation", onOrientationChange )

Hope this helps.

If I get you correctly you just want one message and alter the text depending on orientation?

local message = display.newText("Portrait", display.contentWidth/2, display.contentHeight/2, native.systemFont, 24) local function onOrientationChange (event) if (event.type =="landscapeRight" or event.type == "landscapeLeft") then local newAngle = message.rotation - event.delta transition.to( message, {time= 150, rotation = newAngle}) message.text="Landscape" else local newAngle = message.rotation - event.delta transition.to( message, {time= 150, rotation = newAngle}) message.text="Portrait" end end Runtime:addEventListener( "orientation", onOrientationChange )

Hope this helps.