manually changing of screen orientation

Hello!

I have the issue:
one of my scene must be landscapeRight but the other scenes must be portrait.
It is not a vary convinient to develop when your x and y is rotated for 90 degrees and you have to rotate all your images.

Is there any way for switching orientation manually or to change x and y coordinate system in the particular scene?

Thanks! [import]uid: 106224 topic_id: 32449 reply_id: 332449[/import]

@golubev9,

You can place all of the content for the scene that needs to rotate in a display group and rotate the display group.

Assuming your group is named ‘rotator’, you could have a button rotate the scene like this:

onRotate= function ( event )  
 if( event.phase ~= "ended" )   
 then return true  
 end   
  
 if(rotator.rotation == 0 ) then  
 rotator:setReferencePoint( display.CenterReferencePoint )  
 transition.to( rotator, {rotation=90, time = 500} )  
  
 else  
 rotator:setReferencePoint( display.CenterReferencePoint )  
 transition.to( rotator, {rotation=0, time = 500} )  
 end  
  
 return true  
end  

Please note: All objects within the group (rotator) still have their axes updated relative to the rotator. i.e. When rotated to 90-degrees, Adding 10 to an object’s x translates to adding 10 to the y position as it is rendered.

Here is a sample of what this in action:
http://www.youtube.com/watch?v=JBcXvUssPaw

Edit: If I wasn’t clear above, put all of your content in a display group and put that group in screenGroup:

  
local rotator  
  
function scene:createScene( event )  
 screenGroup = self.view  
  
 rotator = display.newGroup() -- This is the group that gets rotated  
  
 screenGroup:insert( rotator )   
  
 -- After this, add your content to rotator, NOT screenGroup  
end  

[import]uid: 110228 topic_id: 32449 reply_id: 129100[/import]

Thanks!
But rotate a screen is not an issue.
I want to have in the first scene the “landscapeRite” orientation and in the second scene “portrait” orientation, but in config.lua I can’t write orientations for each scene separatly, it is only for the whole application (maybe I’m wrong?) or maybe Corona can change the coordinates and place the axis in different ways (not only in 0,0 in left top corner).
That’s why I asking for “manually” changing, I mean maybe some code in a head of the file, which is changing orientation or axises [import]uid: 106224 topic_id: 32449 reply_id: 129120[/import]

@golubev9,

You can place all of the content for the scene that needs to rotate in a display group and rotate the display group.

Assuming your group is named ‘rotator’, you could have a button rotate the scene like this:

onRotate= function ( event )  
 if( event.phase ~= "ended" )   
 then return true  
 end   
  
 if(rotator.rotation == 0 ) then  
 rotator:setReferencePoint( display.CenterReferencePoint )  
 transition.to( rotator, {rotation=90, time = 500} )  
  
 else  
 rotator:setReferencePoint( display.CenterReferencePoint )  
 transition.to( rotator, {rotation=0, time = 500} )  
 end  
  
 return true  
end  

Please note: All objects within the group (rotator) still have their axes updated relative to the rotator. i.e. When rotated to 90-degrees, Adding 10 to an object’s x translates to adding 10 to the y position as it is rendered.

Here is a sample of what this in action:
http://www.youtube.com/watch?v=JBcXvUssPaw

Edit: If I wasn’t clear above, put all of your content in a display group and put that group in screenGroup:

  
local rotator  
  
function scene:createScene( event )  
 screenGroup = self.view  
  
 rotator = display.newGroup() -- This is the group that gets rotated  
  
 screenGroup:insert( rotator )   
  
 -- After this, add your content to rotator, NOT screenGroup  
end  

[import]uid: 110228 topic_id: 32449 reply_id: 129100[/import]

Thanks!
But rotate a screen is not an issue.
I want to have in the first scene the “landscapeRite” orientation and in the second scene “portrait” orientation, but in config.lua I can’t write orientations for each scene separatly, it is only for the whole application (maybe I’m wrong?) or maybe Corona can change the coordinates and place the axis in different ways (not only in 0,0 in left top corner).
That’s why I asking for “manually” changing, I mean maybe some code in a head of the file, which is changing orientation or axises [import]uid: 106224 topic_id: 32449 reply_id: 129120[/import]

@golubev9,

Sorry for the delay, but I’ve been very busy working on SSKCorona and other stuff.

I don’t know of a way to do this in the config.lua file, but I still think you can use a derivative of what I showed you above.

Simply rotate the scenes that need to be rotated and leave the others in whatever default rotation you’ve selected.

[code]
– pseudo code for scene creation
local lwidth = _w
locsl lheight = _h

if( sceneRequiresRotation ) then
– rotate the scene and set up variables to keep track of new width & height
rotator.rotation = 90
lwidth = _h
lheight = _w
else
– rotate the scene and set up variables to keep track of new width & height
rotator.rotation = 0
lwidth = _w
lheight = _h
end

– Now build scene as you normally would.
[/code] [import]uid: 110228 topic_id: 32449 reply_id: 129350[/import]

@golubev9,

Sorry for the delay, but I’ve been very busy working on SSKCorona and other stuff.

I don’t know of a way to do this in the config.lua file, but I still think you can use a derivative of what I showed you above.

Simply rotate the scenes that need to be rotated and leave the others in whatever default rotation you’ve selected.

[code]
– pseudo code for scene creation
local lwidth = _w
locsl lheight = _h

if( sceneRequiresRotation ) then
– rotate the scene and set up variables to keep track of new width & height
rotator.rotation = 90
lwidth = _h
lheight = _w
else
– rotate the scene and set up variables to keep track of new width & height
rotator.rotation = 0
lwidth = _w
lheight = _h
end

– Now build scene as you normally would.
[/code] [import]uid: 110228 topic_id: 32449 reply_id: 129350[/import]