Subscribe to web2feel.com
Subscribe to web2feel.com

Welcome to My Website

ShaTechs... Technology at your reach...

How to create a cocos2d app in android SDK

Posted by shajir Friday, June 17, 2011 3 comments

We can create a simple cocos2d helloWorld app in android sdk simply by follow the steps below. Before that you need eclipse in your system with android sdk.

1. Open eclips and select File-->New-->Android Project,    then you got a window like this


 2. You just name the project and other fields like in the image and hit the finish button. Now your project is in workspace


3. Open your project --> src --> com.shatechs.firstcocos2d and double click on the java file. Now your java file appears on the code window as below.


4.  After that you right click on project folder -->new-->folder and named as libs. Then you download cocos2d-android.jar   and copy to the libs folder.

5.  Then right click on cocos2d-android.jar --> Build Path-->Add to Build Path. Now the jar file is added.

6. Now replace the Activity class with the following code

    CCGLSurfaceView mGLSurfaceView;
   
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
     // Hiding the app's title from the screen
        requestWindowFeature(Window.FEATURE_NO_TITLE);
       
        // set the screen flag to full screen
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
       
        // Keeps screen active
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
                WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

        mGLSurfaceView = new CCGLSurfaceView(this);
       
        // set the view as mGLSurfaceView
        setContentView(mGLSurfaceView);
    }
    @Override
    public void onStart() {
       
        super.onStart();

        // attach the OpenGL view to a window
        CCDirector.sharedDirector().attachInView(mGLSurfaceView);
       
        //Change the device orientation to Portrait
        CCDirector.sharedDirector().setDeviceOrientation(CCDirector.kCCDeviceOrientationLandscapeLeft);
       
        // set false to disable FPS display, but don't forget to put fps_images.png in the assets folder
        CCDirector.sharedDirector().setDisplayFPS(true);
       
        // set frame rate
        CCDirector.sharedDirector().setAnimationInterval(1.0f / 60);
       
        // Create an instance of scene from HelloWorldLayer class
        CCScene scene = HelloWorldLayer.scene();
       
        // Make the Scene active
        CCDirector.sharedDirector().runWithScene(scene);
       
    }

    @Override
    public void onPause() {
        super.onPause();
        CCDirector.sharedDirector().pause();
    }

    @Override
    public void onResume() {
        super.onResume();
        CCDirector.sharedDirector().resume();
    }

    @Override
    public void onStop() {
        super.onStop();
        CCDirector.sharedDirector().end();
    }

 5. After closing the Activity class add the following class by just copy pasting

class HelloWorldLayer extends CCLayer  {
   
    //Gets screen size of the android device
    CGSize s = CCDirector.sharedDirector().winSize();
   
    public static CCScene scene() {
       
        //Creates scene
        CCScene scene = CCScene.node();
       
        //creates an instance of HelloWorldLayer
        CCLayer layer = new HelloWorldLayer();
       
        //adds layer to scene
        scene.addChild(layer);
       
        return scene;
       
    }

    protected HelloWorldLayer() {
       
        CCLabel lab = CCLabel.makeLabel("Hello World", "serif", 40);
        lab.setPosition(240, 160);
        addChild(lab);

    }
}


6. Download the following image and copy to the asset folder

7. You completed your first android cocos2d project just now. Now you can build and run the project


Note: For getting the emulator in landscape mode press Ctrl+F12/F11 .

At first you download and install the cocos2D library to your mac. The instructions for downloading and installations are available from here.
Now you can create cocos2D iphone application in your xcode simply by following the steps given below,

  1. Start xcode and select cocos2d
 
       2. then name your project and push okey


   3. you can see your helloworld scene from the class folder now


   4. Now build and run.  Wow you created your first cocos2d app..


 Now the time for adding sprites, buttons etc and make a good looking iphone app.

Cocos2D-iPhone-Extensions is a collection of quality 3rd party extensions and additions for the Cocos2D-iPhone Engine.
Many Cocos2D developers love to share code on their blogs & cocos2d forum. With this approach it is difficult to find the code or know if the code is compatible with latest cocos2d source. Many developers are forced to reinvent the wheel, and this leads to multiple duplicates of the same functionality, sometimes even with exact the same class names (good example – CCSlider, there are at least 3 absolute independent versions of it )
Cocos2D-iPhone-Extensions were created to stop such things and combine all cool extensions in one place, so it will be easy to find, use and maintain them.

Everything that doesn’t modify Cocos2D itself, while bringing new functionality can become a part of Cocos2D-iPhone-Extensions Repo: alternative versions of existing classes, additional categories, new nodes, actions, etc…
All extensions are well documented,shipped with testcases and are compatible with latest stable Cocos2D-iPhone version. With rare exceptions, they are designed for both Mac & iOS.
Build & Runtime Requirements are the same as for cocos2d-iphone engine ( Mac OS X 10.6+, Xcode 3.2.3+, iOS 3.0+  )
As well as Cocos2D, Cocos2D Extensions are licensed under the MIT License.
Extensions available in this release (v0.1.1):
  • [iOS/Mac] CCMenuAdvanced – CCMenu subclass with additional features: relativeAnchor, more align options, priority property, scrolling with swipe/trackpad/mousewheel
  • [iOS/Mac] CCMenuItemSpriteIndependent – CCMenuItemSprite Subclass, that doesn’t add normal/selected/disabled images (sprites) as children. It retains them and delegates rect & convertToNodeSpace: methods to normalImage_. So it’s possible to use CCSpriteBatchNode & add position sprites of menuItem anyway you want.
  • [iOS/Mac] CCVideoPlayer – Simple Video Player for Cocos2D apps.
  • [iOS/Mac] CCBigImage – Dynamic Tiled Node for holding Large Images.
  • [iOS/Mac] CCSlider – Little Slider Control to allow the user to set the music/sfx/etc level in the range of 0.0f to 1.0f.
  • [iOS/Mac] CCSendMessages – CCActionInstant subclass, that is more flexible than other CCActions that run functions. Can be used in many cases as blocks replacement.
  • [iOS] CCScrollLayer – CCLayer subclass that lets you pass-in an array of layers and it will then create a smooth scroller. Complete with the “snapping” effect.
  • [iOS/Mac] FilesDownloader – Downloader for a group of files with shared source path.
Cocos2D-iPhone-Extensions isn’t one man project – it’s a centralized repo of different developers extensions. So i wanted to ask all of you: please take a look at the extensions repo and help us to expand it!
To use any extension from the cocos2d-iphone-extensions repo – just import the extension folder (i.e. Extensions/CCMenuAdvanced) to your project. If there will be any additional dependencies – they will be mentioned in the extension README file in the same folder.

For More

Follow steps below
1) In GameConfig.h
       change to  
       #define GAME_AUTOROTATION kGameAutorotationNone

2) InRootViewController.m commenting the following lines as
/*
#elif GAME_AUTOROTATION==kGameAutorotationCCDirector
    //
    // EAGLView will be rotated by cocos2d
    //
    // Sample: Autorotate only in landscape mode
    //
    if( interfaceOrientation == UIInterfaceOrientationLandscapeLeft ) {
        [[CCDirector sharedDirector] setDeviceOrientation: kCCDeviceOrientationLandscapeRight];
    } else if( interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
        [[CCDirector sharedDirector] setDeviceOrientation: kCCDeviceOrientationLandscapeLeft];
    }
   
    // Since this method should return YES in at least 1 orientation,
    // we return YES only in the Portrait orientation
    return ( interfaceOrientation == UIInterfaceOrientationPortrait );
*/
3) In AppDelegate.m commenting these lines 
/*
#if GAME_AUTOROTATION == kGameAutorotationUIViewController
    [director setDeviceOrientation:kCCDeviceOrientationPortrait];
#else
    [director setDeviceOrientation:kCCDeviceOrientationLandscapeLeft];
#endif
*/
and add the following line of code
  [director setDeviceOrientation:kCCDeviceOrientationPortrait];
Done!!!! Now your app is on portrait mode..

What is Web feed

Posted by shajir 0 comments

A web feed (or news feed) is a data format used for providing users with frequently updated content. Content distributors syndicate a web feed, thereby allowing users to subscribe to it. Making a collection of web feeds accessible in one spot is known as aggregation, which is performed by an aggregator. A web feed is also sometimes referred to as a syndicated feed.



A typical scenario of web feed use is: a content provider publishes a feed link on their site which end users can register with an aggregator program (also called a feed reader or a news reader) running on their own machines; doing this is usually as simple as dragging the link from the web browser to the aggregator. When instructed, the aggregator asks all the servers in its feed list if they have new content; if so, the aggregator either makes a note of the new content or downloads it. Aggregators can be scheduled to check for new content periodically. Web feeds are an example of pull technology, although they may appear to push content to the user.
The kinds of content delivered by a web feed are typically HTML (webpage content) or links to webpages and other kinds of digital media. Often when websites provide web feeds to notify users of content updates, they only include summaries in the web feed rather than the full content itself.
Web feeds are operated by many news websites, weblogs, schools, and podcasters.

What is RSS

Posted by shajir 0 comments

        RSS is a technology that is being used by millions of web users around the world to keep track of their favorite websites. RSS (most commonly expanded as Really Simple Syndication) is a family of web feed formats used to publish frequently updated works—such as blog entries, news headlines, audio, and video—in a standardized format.

In the ‘old days’ of the web to keep track of updates on a website you had to ‘bookmark’ websites in your browser and manually return to them on a regular basis to see what had been added.
There is some problems regarding with bookmarking such as
  • You as the web surfer had to do all the work
  • It can get complicated when you are trying to track many websites at once
  • You miss information when you forget to check your bookmarks
  • You end up seeing the same information over and over again on sites that don’t update very often
What if you could tell a website to let you know every time that they update? In a sense, this is what RSS does for you.
An RSS document (which is called a "feed", "web feed", or "channel") includes full or summarized text, plus metadata such as publishing dates and authorship. 

Web feeds benefit publishers by letting them syndicate content automatically. They benefit readers who want to subscribe to timely updates from favored websites or to aggregate feeds from many sites into one place. RSS feeds can be read using software called an "RSS reader", "feed reader", or "aggregator", which can be web-based, desktop-based, or mobile-device-based. A standardized XML file format allows the information to be published once and viewed by many different programs. The user subscribes to a feed by entering into the reader the feed's URI or by clicking a feed icon in a web browser that initiates the subscription process. The RSS reader checks the user's subscribed feeds regularly for new work, downloads any updates that it finds, and provides a user interface to monitor and read the feeds. RSS allows users to avoid manually inspecting all of the websites they are interested in, and instead subscribe to websites such that all new content is pushed onto their browsers when it becomes available. 

GPS iPhone Module

Posted by shajir 0 comments

Connected the SiRF III EM-408 GPS module to a thin PCB and an iPhone connector. The RX and TX lines of the GPS module are connected to the corresponding signals of the iPod connector to allow communication between the two devices and power is taken from the iPhone connector. This could be used with a custom application on the iPod Touch or the iPhone (without on-board GPS) to receive location information.



This is not a plug-and-play GPS solution for the iPhone. A custom application which communicates with the GPS module through the hardware interface must be used to receive location information.

This serial modem brought to you by Switch Science allows you to interface an Arduino board with your iPhone or Android smart phone through the audio jack. Now you can integrate your smart phone into your next embedded project. Some software is required on the phone side, and of course there is an Arduino library.




Because the modem and supporting software exploits a connection originally intended for audio, some corruption of the serial data is to be expected from time to time. It's recommended that you keep this in mind when writing your code. See the links below for more information on the board, the Arduino library, and how to implement it.
A standard 3.5mm stereo headphone cable will not work correctly with this board. You must use the special 4-pole cable such as you would find on a wired headset. The audio jack shown does come with the board, but is not soldered to the board.
More Details..

Cocos 2D

Posted by shajir Friday, June 10, 2011 0 comments

Cocos2D is the leading, open-source, royalty-free smartphone game engine. It’s easy to use, community-supported, reliable, mature, and over 1500 mobile iOS games have been published using it! And now, thanks to Cocos2D-X, it’s possible to release games for Android with the same codebase.
You can play a sound effect, animate a flipping sprite, flash some rad custom font, all with just a couple lines of simple, pure Objective C code. No knowledge of OpenGL is required! Rotating, mirroring, parallaxing, scaling, tinting, sliding, jumping, and a Halloween-sackful of other effects are quickly at your fingertips.
Simply cocos2d is a framework for building 2D games, demos, and other graphical/interactive applications. 

main features

  • Flow control: Manage the flow control between different scenes in an easy way
  • Sprites: Fast and easy sprites
  • Actions: Just tell sprites what you want them to do. Composable actions like move, rotate, scale and much more
  • Effects: Effects like waves, twirl, lens and much more
  • Tiled Maps: Support for rectangular and hexagonal tiled maps
  • Transitions: Move from scene to scene with style
  • Menus: Built in classes to create menus
  • Text Rendering: Label and HTMLLabel with action support
  • Documentation: Programming Guide + API Reference + Video Tutorials + Lots of simple tests showing how to use it
  • Built-in Python Interpreter: For debugging purposes
  • BSD License: Just use it
  • Pyglet Based: No external dependencies
  • OpenGL Based: Hardware Acceleration

The following diagram shows the major components of the Android operating system. Each section is described in more detail below.


What is android SDK

Posted by shajir 0 comments

Android is a software stack for mobile devices that includes an operating system, middleware and key applications. The Android SDK provides the tools and APIs necessary to begin developing applications on the Android platform using the Java programming language.
 
It is a software development kit that enables developers to create applications for the Android platform. The Android SDK includes sample projects with source code, development tools, an emulator, and required libraries to build Android applications. Applications are written using the Java programming language and run on Dalvik, a custom virtual machine designed for embedded use which runs on top of a Linux kernel.

Features

  • Application framework enabling reuse and replacement of components
  • Dalvik virtual machine optimized for mobile devices
  • Integrated browser based on the open source WebKit engine
  • Optimized graphics powered by a custom 2D graphics library; 3D graphics based on the OpenGL ES 1.0 specification (hardware acceleration optional)
  • SQLite for structured data storage
  • Media support for common audio, video, and still image formats (MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, GIF)
  • GSM Telephony (hardware dependent)
  • Bluetooth, EDGE, 3G, and WiFi (hardware dependent)
  • Camera, GPS, compass, and accelerometer (hardware dependent)
  • Rich development environment including a device emulator, tools for debugging, memory and performance profiling, and a plugin for the Eclipse IDE

For this we can use vertically and crosswise method.
This can be explain using a simple example 9 x 7
For this subtract 9 from 10 and write the result as 9   1
Then same is doing for 7 ie: 7   3

After that write them on two rows a apply crosswise subtraction

ie:    9    1
           \  |
        7    3  
    (7-1) (1x3)  =  63 that is it.
       or
   (9 -3)
    ie:you get first digit by crosswise and 2nd digit by vertical multiplication of the right side


eg:   6 x 7     is       6   4
                                  \
                               7   3 
                               3  (12)    ie 42

Similar way you can do this method for numbers greater than 50 x 50 as shown below

eg:  84 x 96
                For this   84      (100-84)
                               96       (100-96)  

                     ie:       84    16
                                96      4 
                          (84-4)    4x16            ie:  8064
                             or
                        (96-16)   

Similar way you can do the higher numbers also.

A driver development kit (DDK) is a set of programs and related files that are used to develop a new software or hardware driver or to update an existing legacy application driver for an operating system. (A driver is a relatively small program that addresses the unique requirements of a kind of hardware or a special software application.) Typically, DDKs are used by device manufacturers and software application developers. Some DDKs can be downloaded from the maker of the operating system. Others can be purchased from a third party. A DDK typically includes sample drivers, source code, a debugging utility, a compiler, testing tools, other utilities, and documentation.
In addition to the kit, a driver developer needs to be familiar with the operating system or application the driver is for. Building a driver is typically a complicated process. Testing and debugging should be thorough so that the driver is released with as few errors as possible. There are several steps in building a driver:
  • Writing the driver code. Common programming languages for writing drivers are C and C++.
  • Testing and debugging the driver on a checked build. A checked build is an operating system and kernel-mode driver that has extra error checking and debugging information in the code to aid testing and debugging of the driver. Running with a checked build is slower and uses more memory. A checked build is done in a separate computer from the free build.
  • Testing and debugging the driver on a free build. A free build or retail build is the end user version of the operating system built with full optimization and all debugging information removed. A free build is faster and uses less memory. It also shows driver problems that a user might encounter such as error messages or a computer freeze.
  • Fine-tuning and performance checking of the driver on the free build.
  • Additional testing and debugging as necessary, using both the checked and free builds of the driver.
  • Final testing using the free build. A driver needs testing on a multiprocessor computer as well as on a single processor computer.

Subtracting numbers using vedic maths

Posted by shajir Thursday, June 9, 2011 0 comments


We can easily subtract a big number from powers of 10 using vedic maths by following the steps given below.
We use all from 9 and last from 10 method for this.
For example 
1) 1000 - 639 is as follows

    1000 - 639  =   9-   9-   10-
                             6     3     9   
                             3     6     1
     ie: 1000 - 639  = 361

2) 10000 - 4529  =  9-  9-  9-  10-
                                4   5    2     9   
                                5   4    7     1
     ie: 10000 - 4529  =  5471

3)  1000 - 69     =  9-   9-  10-
                              0    6     9   
                              9    3     1
     ie: 1000  -  69  =  931

Search This Blog