Over the top professionals at your service!
12
May

First display an object :

local triangle = display.newImage("triangle.png")

triangle.x = 200

triangle.y = 150

 

Then, define the shape of the body :

triangleShape = { 0,-35, 37,30, -37,30 }

--Note : These polygon coordinates must be defined in clockwise order.

 

 Add physics to the body and specify the shape :

physics.addBody( triangle, { density=1.6, friction=0.5, bounce=0.2, shape=triangleShape } )

11
May
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

[[UIDevice currentDevice]setOrientation:UIInterfaceOrientationPortrait];
// Add the tab bar controller’s view to the window and display.
[window addSubview:tabBarController.view];
//Take this line this line and put it in your code.
tabBarController.selectedIndex = 2;

[window makeKeyAndVisible];

return YES;
}

,

11
May

You’ll have to implement a URL scheme. For example, if one app’s URL scheme is appone://, then you can launch app one from app two like this:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"appone://"]];

,

11
May

If it is your root view controller, and you have access to your app delegate, you should be able to access your controller like this:

appDelegate.window.rootViewController

,

11
May

Create a separate instance of NSMUtablearray each time you populate and insert it, otherwise you keep re-using the same instance, so only the last state of it appears in each position of the array.

NSMutableArray *myArray = [NSMutableArray array];
for (int i = 0 ; i != 10 ; i++) {
    NSMutableDictionary *m = [NSMutableDictionary dictionary];
    // Presumably, this part is done differently on each iteration
    [m setObject:a forKey:@"a"];
    [m setObject:b forKey:@"b"];
    [m setObject:c forKey:@"c"];
    [m setObject:d forKey:@"d"];
    [myArray addObject:m];
}

, ,

10
May

Include the SystemConfiguration.framework in your project.

Make some imports

#import <sys/socket.h>
#import <netinet/in.h>
#import <SystemConfiguration/SystemConfiguration.h>

Now just call this function

/*
Connectivity testing code pulled from Apple's Reachability Example: http://developer.apple.com/library/ios/#samplecode/Reachability
 */
+(BOOL)hasConnectivity {
    struct sockaddr_in zeroAddress;
    bzero(&zeroAddress, sizeof(zeroAddress));
    zeroAddress.sin_len = sizeof(zeroAddress);
    zeroAddress.sin_family = AF_INET;

    SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr*)&zeroAddress);
    if(reachability != NULL) {
        //NetworkStatus retVal = NotReachable;
        SCNetworkReachabilityFlags flags;
        if (SCNetworkReachabilityGetFlags(reachability, &flags)) {
            if ((flags & kSCNetworkReachabilityFlagsReachable) == 0)
            {
                // if target host is not reachable
                return NO;
            }

            if ((flags & kSCNetworkReachabilityFlagsConnectionRequired) == 0)
            {
                // if target host is reachable and no connection is required
                //  then we'll assume (for now) that your on Wi-Fi
                return YES;
            }

            if ((((flags & kSCNetworkReachabilityFlagsConnectionOnDemand ) != 0) ||
                 (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0))
            {
                // ... and the connection is on-demand (or on-traffic) if the
                //     calling application is using the CFSocketStream or higher APIs

                if ((flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0)
                {
                    // ... and no [user] intervention is needed
                    return YES;
                }
            }

            if ((flags & kSCNetworkReachabilityFlagsIsWWAN) == kSCNetworkReachabilityFlagsIsWWAN)
            {
                // ... but WWAN connections are OK if the calling application
                //     is using the CFNetwork (CFSocketStream?) APIs.
                return YES;
            }
        }
    }

    return NO;
}

, ,

10
May
function setCookie (name, value, expires, path, domain, secure){

var today = new Date();

today.setTime(today.getTime());

if (expires){

expires = expires * 1000 * 60 * 60 * 24;

}

var expires_date = new Date( today.getTime() + (expires));

document.cookie = name+'='+escape( value ) +

((expires) ? ';expires='+expires_date.toGMTString() : '' ) + //expires.toGMTString()

((path) ? ';path=' + path : '' ) +

((domain) ? ';domain=' + domain : '' ) +

((secure) ? ';secure' : '' );

}

function getCookie(name){

var start = document.cookie.indexOf( name + "=" );

var len = start + name.length + 1;

if ((!start) && (name != document.cookie.substring( 0, name.length))){

return null;

}

if (start == -1) return null;

var end = document.cookie.indexOf(';', len);

if (end == -1) end = document.cookie.length;

return unescape(document.cookie.substring(len, end));

}

function deleteCookie (name, path, domain){

if (getCookie(name)) document.cookie = name + '=' +

((path) ? ';path=' + path : '') +

((domain) ? ';domain=' + domain : '' ) +

';expires=Thu, 01-Jan-1970 00:00:01 GMT';

}

,

10
May
NSProgressIndicator * indicator = [[NSProgressIndicator alloc] initWithFrame:NSMakeRect(200,200,500,500)] ;

[indicator setStyle:NSProgressIndicatorSpinningStyle];

[[[CCDirector sharedDirector] openGLView] addSubview:indicator];

[indicator startAnimation:self];

09
May

We can write code to programatically handle the Back button of Windows Phone.

In .xaml file, add this code:

BackKeyPress="PhoneApplicationPage_BackKeyPress"

It should look like:

<phone:PhoneApplicationPage BackKeyPress="PhoneApplicationPage_BackKeyPress"
..//other attributes .. >

In the .cs file, write the function to handle the back key press as follows:

 private void PhoneApplicationPage_BackKeyPress(object sender, System.ComponentModel.CancelEventArgs e)
        {
            MessageBoxResult mb = MessageBox.Show("Do you want to exit the page?", "Alert", MessageBoxButton.OKCancel);
            if (mb == MessageBoxResult.OK)
            {
                if (NavigationService.CanGoBack)
                {
                    while (NavigationService.RemoveBackEntry() != null)
                    {
                        NavigationService.RemoveBackEntry();
                    }
                }
            }
            else
            {
                e.Cancel = true;
            }
        }

All the back entry elements in the stack are deleted after executing this code and the app will exit.

09
May

We can define event listeners in three different ways in Corona, see the examples given below.

– METHOD 1:

    local function touchListener( event )
        ...
    end

    myImage:addEventListener( "touch", touchListener )

———————————————————————-

— METHOD 2:

    local function touchListener( self, event )

        -- In this example, "self" is the same as event.target
        ...
    end

    -- Notice the difference in assigning the event:
    myImage.touch = touchListener
    myImage:addEventListener( "touch", myImage )

———————————————————————-

— METHOD 3:

    function myImage:touch( event )

        -- Same as assigning a function to the .touch property of myImage
        -- This time, "self" exists, but does not need to be defined in
        -- the function's parameters (it's a Lua shortcut).
        ...
    end

    myImage:addEventListener( "touch", myImage )