iOS – UIActivityIndicatorView example…

 UIActivityIndicatorView is used to show that some long process is processing in background.It can be implemented programatically and using IBOutlet.

In this tutorial we are going to create a UIActivityIndicatorView programatically with start and stop animations.Lets get started,

Step 1: Create a new project in Xcode.

Step 2: Set property for UIActivityIndicatorView in .h file and set @synthesis in .m file.

.h file: 

@property (nonatomic,retain) UIActivityIndicatorView *activityIndicatorObject;

.m file:

@synthesis activityIndicatorObject;

Step 3: Now Initialize UIActivityIndicatorView object and set position.

// Initialize ActivityIndicator object

    activityIndicatorObject = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];

// Set Center Position for ActivityIndicator

    activityIndicatorObject.center = CGPointMake(150, 150);

   // Add ActivityIndicator to your view

    [self.view addSubview:activityIndicatorObject];

Step 4: Add two buttons in xib and set Action as stopAnimating and startAnimating.These methods are used to start and stop ActivityIndicator.

- (IBAction)startAnimating:(id)sender

{

[activityIndicatorObject startAnimating]; 

}

 - (IBAction)stopAnimating:(id)sender

{

[activityIndicatorObject stopAnimating];

}

Step 5: Now Run the project.You are Done!!!

 

iOS – UISwitch example…

UISwitch is an component which resembles the electronic switch with animation.We can change the Switch state by manually or programatically.

In this tutorial we are going to change the state of the UISwitch programatically with suitable changing Label text.Lets have a look at this,

Step 1: Create a new ‘Single view’ project in Xcode.

Step 2: Drag and drop components like UISwitch,UILabel and UIButton.Arrange them as shown below,

Step 3:  Right click over the ‘UISwitch’ component.Now drag and drop in the .h file as shown below.Give a name to your UISwitch and UILabel component which will be referenced later.Set method name for the UISwitch and Button as we did before.

@property (weak, nonatomic) IBOutlet UISwitch *switchObject;

@property (weak, nonatomic) IBOutlet UILabel *switchLabel;

- (IBAction)toggleAction:(id)sender;

- (IBAction)switchAction:(id)sender;

Step 4: Include this method in your .m file.

- (IBAction)toggleAction:(id)sender {

    if(switchObject.on)

    {

        [switchObject setOn:NO animated:YES];

                       switchLabel.text  = @"Disabled";

    }

    else

    {

 [switchObject setOn:YES animated:YES];

        switchLabel.text  = @"Enabled";

            }

}

In this method the UISwitch state and label value changes when user pressed the ‘Toggle’ button.

Step 5:Include this method in your .m file.

- (IBAction)switchAction:(id)sender {

    if(switchObject.on)

    {

       switchLabel.text  = @"Enabled";

    }

    else

    {

        switchLabel.text  = @"Disabled";

        }

}

In this method the label value changes when user pressed the UISwitch.

Step 6: Now Run the project.You are done…

cocos2d – HelloWorld in Cocos2d…

After the installation, now we gonna have a look at  HelloWorld program.We are not going to implement any code here.When we create a new project in cocos2d, it automatically builds some code in it.

1.Select File–>New–>Project.

2.A window appears as shown below.

select

3.Select ‘Cocos2d’ and click next.

4.Just run the project.

Output:

iOS Simulator Screen shot 18-May-2013 2.06.30 PM

  • Here a Label with text ‘Hello World’ is displayed.
  • The Numbers displayed below are called as ‘FPS'(Frames Per Second).Number of frames displaying per second.

cocos2d – Installing Cocos2d in Xcode…

Yippee:) So Gaming is always a pleasurable thing.Cocos2d has 2 game engines namely,

  1. Box2d
  2. Chipmunk

While comparing to chipmunk,Bx2d is something added with flavour.OK…

Installing Cocos2d:

1. You can Download COCOS2D latest version from
http://www.cocos2d-iphone.org/download” this link

2. open the terminal and type “cd”

3.Drag your latest version of -> COCOS2D package folder in to your terminal window.

4. Type sudo and open the COCOS2D package folder and drag the “install-templates.sh” file into your terminal     windows and press enter.

6. put your system password to install templates.

Enjoy gaming!!!

cocos2d – Introduction cocos2d…

cocos2d

Cocos2d

It is a framework for building 2D games, demos, and other graphical/interactive applications. It is based on the cocos2d design: it uses the same concepts, but instead of using python it uses objective-c. cocos2d for iPhone is:

  • Easy to use: it uses a familiar API, and comes with lots of examples
  • Fast: it uses the OpenGL ES best practices and optimized data structures
  • Flexible: it is easy to extend, easy to integrate with 3rd party libraries
  • Free: is open source, compatible both with closed and open source games
  • Community supported: cocos2d has an active, big and friendly community (forum, IRC)
  • AppStore approved: More than 2500 AppStore games already use it, including many best seller games.

cocos2d for iPhone supports: iPod TouchiPhoneiPad and OS X

Features:

  • Scene management (workflow)
  • Transitions between scenes
  • Sprites and Sprite Sheets
  • Effects: Lens, Ripple, Waves, Liquid, Twirl, etc.
  • Actions (behaviors):
    • Trasformation Actions: Move, Rotate, Scale, Jump, etc.
    • Composable actions: Sequence, Spawn, Repeat, Reverse
    • Ease Actions: Exp, Sin, Cubic, etc.
    • Misc actions: CallFunc, OrbitCamera
  • Basic menus and buttons
  • Integrated physics engine (both Box2d and Chipmunk)
  • Particle system
  • Text rendering support (variable and fixed width fonts)
  • Texture Atlas support
  • Tile Map support (TMXmaps):
    • Orthogonal maps
    • Isometric maps
    • Hexagonal maps
  • Parallax scrolling support
  • Sound support
  • Streak Motion support
  • Render Texture support
  • High Score server (Cocos Live)
  • Point based API: Supports Retina Display
  • Touch/Accelerometer support (iOS).  Keyboard / Mouse support (Mac)
  • Portrait and Landscape mode (iOS) / Automatic Fullscreen support (Mac)
  • Integrated Pause/Resume
  • Fast Textures:Supports PVRTC textures, 8-bit textures, 16-bit textures and 32-bit textures
  • Language: objective-c
  • OpenGL ES 1.1 based (iOS) / OpenGL 1.5 based (Mac)

courtesy:http://www.cocos2d-iphone.org