Showing posts with label alert. Show all posts
Showing posts with label alert. Show all posts

Friday, 23 August 2013

Different device Orientation in Corona SDK

In this tutorial, we will teach you: how to setup different supported orientations
for your Corona SDK application. These tricks are done in the build.settings file.
It will setup app orientation in relation to the device's physical orientation.
This also includes auto orientation triggered by the accelerometer, if the
device is flipped/rotated during runtime.

By this, you can set the orientation for:
    1) Launch image(splash screen).
    2) Native UI elements(like alerts, native keyboard,etc).
    3) The Corona display stage.
   
We will show you some of the examples in different orientations.

Example 1: Only landscapeLeft
 

    settings =
        {
            orientation =
            {
                default = "landscapeRight",
            },
        }



 
Example 2: Both landscapeLeft and landscapeRight


    settings =
    {
        orientation =
        {
            default = "landscapeRight",
            supported = { "landscapeLeft", "landscapeRight" },
        },
    }


   
Example 3: Only portrait    
 


    settings =
        {
            orientation =
            {
                default = "portrait",
            },
        }




Example 4: Both portrait and portraitUpsideDown


    settings =
    {
        orientation =
        {
            default = "portrait",
            supported = { "portrait", "portraitUpsideDown" },
        },
    }




Wednesday, 7 August 2013

How to create a native alert view using corona SDK



The below function defines the two alert button ('Learn More' & 'OK') actions:

local function onClick(e) 
    if e.action == "clicked" then 
        if e.index == 1 then 
            -- Do something
        elseif e.index == 2 then 
            system.openURL( "http://devblogdk.blogspot.in/" ) 
        end 
    end 
end 

The below code generates the native alertview with title, subject and two buttons:

local alert = native.showAlert("Welcome", "Development Tutorials on DevBlogDK", {"OK", "Learn More"}, onClick)

Saturday, 1 June 2013

How to create UIAlert View: cocos2d/Xcode


Syntax:

    [self Alertfunction];   // Call Alertfunction


    -(void)Alertfunction {
       
        UIAlertView* dialog = [[UIAlertView alloc] init];
        [dialog setDelegate:self];
        [dialog setTitle:@"Title"];
        [dialog setMessage:@"Do you want to play again?"];
        [dialog addButtonWithTitle:@"Yes"];
        [dialog addButtonWithTitle:@"No"];
        [dialog show];
        [dialog release];
    }


    - (void) alertView:(UIAlertView *)alert clickedButtonAtIndex:(NSInteger)buttonIndex
        {
            if(buttonIndex==0) {
                //do stuff for first button click
            }
            else
                //do stuff for second button click
            }
        }