[Resolved] Perform some action when device is rotated counter clock wise

Hi All,

I need help. Actually I am working on an app in which I need to perform some action when device is rotated counter clock wise and orientation of device changes from portrait to landscape. Now when device is rotated back to the portrait position original setting are restored.

Now it is like this!

I have a some images and text displayed on the screen. Now when device is rotated counter clock wise I need one of the images to be displayed occupying the full screen in landscape mode. When device is rotated back to portrait mode, the image which was displayed on full screen goes back to its original position and other content is also displayed and app starts to behave as normal.

I will be really thankful for help.

Thanks & Regards [import]uid: 126619 topic_id: 33051 reply_id: 333051[/import]

@rhmueed,

You’ll want to use the Runtime event ‘orientation’ to catch this.

You’ll need to hunt around a bit, but here are some links and an example to get you started:
http://docs.coronalabs.com/api/event/orientation/index.html
http://developer.coronalabs.com/content/application-programming-guide-event-handling
Example

  1. Plop this sample code in a blank main.lua file
    [lua]function onOrientationChange( event )
    print("event.name == " … event.name )
    print(“event.type == " … event.type )
    print(“event.delta == " … event.delta )
    print(””)
    return true
    end

Runtime:addEventListener( “orientation”, onOrientationChange )[/lua]

  1. Load it in the simulator

  2. Tell the simulator to rotate (CTRL + Right/Left Arrow on Windows)

  3. Look at the console window for messages.
    [import]uid: 110228 topic_id: 33051 reply_id: 131264[/import]

Thanks :slight_smile: [import]uid: 126619 topic_id: 33051 reply_id: 131275[/import]

@rhmueed,

You’ll want to use the Runtime event ‘orientation’ to catch this.

You’ll need to hunt around a bit, but here are some links and an example to get you started:
http://docs.coronalabs.com/api/event/orientation/index.html
http://developer.coronalabs.com/content/application-programming-guide-event-handling
Example

  1. Plop this sample code in a blank main.lua file
    [lua]function onOrientationChange( event )
    print("event.name == " … event.name )
    print(“event.type == " … event.type )
    print(“event.delta == " … event.delta )
    print(””)
    return true
    end

Runtime:addEventListener( “orientation”, onOrientationChange )[/lua]

  1. Load it in the simulator

  2. Tell the simulator to rotate (CTRL + Right/Left Arrow on Windows)

  3. Look at the console window for messages.
    [import]uid: 110228 topic_id: 33051 reply_id: 131264[/import]

Thanks :slight_smile: [import]uid: 126619 topic_id: 33051 reply_id: 131275[/import]