Draw primitive shapes such as rectangle, circle etc in ANDROID, A simple example.
The following example shows how to draw a rectangle using the Paint Class in ANDROID. Just copy and paste the following code to your file and you are done.
The following example shows how to draw a rectangle using the Paint Class in ANDROID. Just copy and paste the following code to your file and you are done.
With the following code you can load images in your drawable folder dynamically by giving the filename as a String. For that you have to use getResources().getIdentifier which has parameters as the “path”,”drawable” and the “package name”. This returns a unique resource ID which can be used to set the image for a ImageView using… Read More »
In ANDROID all resource has a unique resource ID which we get by passing the song name to the function below playSong(). The function getAllResourceIDs() will convert this String which is the name of the song to the unique resource ID which can then be used to play the song. setOnCompletionListener() will be executed when… Read More »
The function for trim in ActionScript is defined inside StringUtil Class. Checkout the following function. public function stringTrim(result:String):String{ result = StringUtil.trim(result); trace(result); return result; } Please post your valuable comments if the post was useful. The function for trim in ActionScript is defined inside StringUtil Class. Checkout the following function. public function stringTrim(result:String):String{ result =… Read More »
You cal also animate CCMenu like other sprites to have some effect on your Menu. You can also place spritesheets in each MenuItem. -(void) setUpMenu { CCSprite *Home1 = [CCSprite spriteWithFile:@”Home1.png”]; CCSprite *Home2 = [CCSprite spriteWithFile:@”Home1.png”]; Home2.opacity = 100; CCSprite *Levels1 = [CCSprite spriteWithFile:@”levels2.png”]; CCSprite *Levels2 = [CCSprite spriteWithFile:@”levels2.png”]; Levels2.opacity = 100; CCSprite *Refresh1 =… Read More »
Access a remote database from Adobe AIR or FLEX. Many often you need to access online database from your application. For doing it in Adobe AIR of FLEX you need HttpService. The following example shows how to access an online database from an AIR Application. Note that you cannot return an array from a remote… Read More »
Follow these steps…. Select your particle system from the Particle Designer . The go to file-> save as “file.plist” Copy file.plist to your resources folder. Copy the following code to your Xcode.
Simply copy and paste the following code to see how to use the RatingBar in ANDROID.
Below code shows how to crop an image in Adobe AIR. Change the mx:WindowedApplication to mx: Application to run it as a FLEX Application. The code uses copyPixels to extract the desired part from the image file. The important line in the below code crops the image. cropBD.copyPixels(loadBD, new Rectangle(startPoint.x, startPoint.y, squareSize, squareSize),posPoint);
StyleManager can be used to change the theme of any control in Adobe AIR and Flex. The code shows how to sue StyleManager and dynamically change the theme of your window and others. HBox{ backgroundColor: #ffffff; }
Change the background of your window with your selected image. Copy and paste the following code to your AIR file and view the result. Note: Please make sure that you have an image in your application source folder. Here the image name is “image.jpg” else you will get URL not found error.
We often need to access another window variable in the current window. The following example shows how to access a variable from one window in the next window. The logic is to create an object of next window in the current window and assign the value of variable in the current window itself so that… Read More »
The below function creates a polygon in the shape of a triangle. Please call the debugdraw function inside your update method to view the results. Make sure you import the Box2D classes into your file. public function init():void { debug_draw(); addEventListener(Event.ENTER_FRAME, update); createTriangle(); } public function createTriangle():void { var fd : b2FixtureDef = new b2FixtureDef();… Read More »
Everyone will be fascinated how flash games are built on the web that implements the real world physics. Well for your information there are a lot of physics engines available. One of them is the Box2D. Box2D was written in C++. Then it was converted to flash. So now I am going to show you… Read More »
Here mybody is a body to which I am connecting a pinpoint. The pin joint is between the world and the body. So it will appear as hanging in the wall if the gravity is downwards. ‘The ground’ is the other body to which the my_body is connected. First you create a big ground body… Read More »
You can iterate through all bodies in the world and check whether you have touched a particular body. You can get all the userdata from the current body The userdata contains the width, height, sprite etc. Just Log the userdata in the current body to see all these. for (b2Body* b = world->GetBodyList(); b; b… Read More »
Below code is a simplest way to do that.
You can check it by using the TestPoint function available for the Fixtures.
write the below code in “ccTouchesBegan” function and you are done. Here the ballBody represents the bullet body. You can increase the power variable to increase bullet speed.
The below code helps you to rotate a body in Box2D manually. Here the body is named “rotating_body” which is going to rotate and a sprite named “rot_sprite” is it’s userData, please give your own image for it. Make sure that you have it in your resources otherwise your program will crash. Note: call this… Read More »
Please checkout the “LogCat” for the output. If you don’t know about Logcat In Eclipse “Go to Window->showView and search for Logcat”.
Please checkout the “LogCat” for the output. If you don’t know about Logcat In Eclipse “Go to Window->showView and search for Logcat”.
Please checkout the “LogCat” for the output. If you don’t know about Logcat In Eclipse “Go to Window->showView and search for Logcat”.
The following java code helps you to show a webpage in ANDROID and enable javascript.