Developing a clothing game for Android


SDK Version: 
M3
What the hell am I doing? Developing a clothing game for Android...

Last time I was really bored, i tried to make a simple clothing game for android.

Here is the tutorial:

On the first google image page of results for android there is a cute robot image:


In photoshop you can use the slice tool to cutting this robot into slices:


After that save the image using the 'Save for Web...' option. Here you should set every silice's settings like this:

After that create a new android project in eclipse, then copy thoose images into drawable folder.

Modify the main.xml like this:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout android:id="@+id/LinearLayout01"; xmlns:android="http://schemas.android.com/apk/res/android"
  3.  
  4. android:orientation="vertical" android:layout_height="wrap_content" android:layout_width="wrap_content">
  5. <LinearLayout android:id="@+id/LinearLayout02"; android:layout_width="wrap_content" android:layout_height="wrap_content"><ImageView
  6.  
  7. android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/horn" android:id="@
  8.  
  9. +id/horn"></ImageView>
  10. </LinearLayout>
  11. <LinearLayout android:id="@+id/LinearLayout03"; android:layout_width="wrap_content" android:layout_height="wrap_content"><ImageView
  12.  
  13. android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/head" android:id="@
  14.  
  15. +id/head"></ImageView>
  16. </LinearLayout>
  17. <LinearLayout android:id="@+id/LinearLayout04"; android:layout_width="wrap_content" android:layout_height="wrap_content"
  18.  
  19. android:orientation="horizontal"><ImageView android:layout_width="wrap_content" android:layout_height="wrap_content"
  20.  
  21. android:src="@drawable/leftarm" android:id="@+id/leftarm"></ImageView>
  22. <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/body" android:id="@
  23.  
  24. +id/body"></ImageView>
  25. <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/rightarm"
  26.  
  27. android:id="@+id/rightarm"></ImageView>
  28. </LinearLayout>
  29. <LinearLayout android:id="@+id/LinearLayout05"; android:layout_width="wrap_content" android:layout_height="wrap_content"
  30.  
  31. android:orientation="horizontal"><ImageView android:layout_width="wrap_content" android:layout_height="wrap_content"
  32.  
  33. android:src="@drawable/leftnothing&quot; android:id="@+id/leftnothing"></ImageView>
  34. <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/legs" android:id="@
  35.  
  36. +id/legs"></ImageView>
  37. <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/rightnothing&quot;
  38.  
  39. android:id="@+id/rightnothing"></ImageView>
  40. </LinearLayout>
  41.  
  42. </LinearLayout>

Then check the layout, your robot should be ready to clothing :)

Use photoshop or mspaint or anything else to edit the slices, than save them. Use the original file names plus a number, for example
head2, head3, horn2, horn3...
Use your fantasy :)


After that create an itemselect.xml file, than modify like this:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout android:id="@+id/LinearLayout01"; xmlns:android="http://schemas.android.com/apk/res/android"
  3.  
  4. android:layout_height="wrap_content" android:layout_width="wrap_content" android:orientation="vertical">
  5.  
  6. <ImageView android:id="@+id/first" android:layout_width="wrap_content" android:layout_height="wrap_content"></ImageView>
  7. <ImageView android:id="@+id/second" android:layout_width="wrap_content" android:layout_height="wrap_content"></ImageView>
  8. <ImageView android:id="@+id/third" android:layout_width="wrap_content" android:layout_height="wrap_content"></ImageView>
  9.  
  10. </LinearLayout>

This is the easiest way to select the new body part, using an existing imageview.

After that create a new class, called DataStorage.java. This class helps you to save and load the parts of your droid.
Use that methods:

  1.         private SharedPreferences mPrefs;
  2.         public DataStorage(Context context){
  3.                 mPrefs = PreferenceManager.getDefaultSharedPreferences(context);
  4.         }
  5.        
  6.         public void setHead(int id){
  7.                 SharedPreferences.Editor edit=mPrefs.edit();
  8.                 edit.putInt("head", id);
  9.                 edit.commit();
  10.                
  11.                 }
  12.         public int getHead(){
  13.                 return mPrefs.getInt("head",0);
  14.         }
  15.         public void setHorn(int id){
  16.                 SharedPreferences.Editor edit=mPrefs.edit();
  17.                 edit.putInt("horn", id);
  18.                 Log.d("savehorn:",""+id);
  19.                 edit.commit();
  20.                 }
  21.         public int getHorn(){
  22.                 return mPrefs.getInt("horn",0);
  23.         }
  24.         public void setLeftHand(int id){
  25.                 SharedPreferences.Editor edit=mPrefs.edit();
  26.                 edit.putInt("lefthand", id);
  27.                 edit.commit();
  28.                 }
  29.         public int getLeftHand(){
  30.                 return mPrefs.getInt("lefthand",0);
  31.         }
  32.         public void setRightHand(int id){
  33.                 SharedPreferences.Editor edit=mPrefs.edit();
  34.                 edit.putInt("righthand", id);
  35.                 edit.commit();
  36.                 }
  37.         public int getRightHand(){
  38.                 return mPrefs.getInt("righthand",0);
  39.         }
  40.         public void setLegs(int id){
  41.                 SharedPreferences.Editor edit=mPrefs.edit();
  42.                 edit.putInt("legs", id);
  43.                 edit.commit();
  44.                 }
  45.         public int getLegs(){
  46.                 return mPrefs.getInt("legs",0);
  47.         }
  48.        
  49.         public void setBody(int id){
  50.                 SharedPreferences.Editor edit=mPrefs.edit();
  51.                 edit.putInt("body", id);
  52.                 edit.commit();
  53.                 }
  54.         public int getBody(){
  55.                 return mPrefs.getInt("body",0);
  56.         }
  57.        

I wrote a ClickListener method. It helps you to save your clicked body part, than retuns to main screen.

  1.         public void ClickListener(ArrayList<ImageView> im, final int i, final int bodypart, final DataStorage ds, final Context
  2.  
  3. context ){
  4.                 im.get(i).setOnClickListener(new OnClickListener(){
  5.                         @Override
  6.                         public void onClick(View v) {
  7.                                 //ds.setHorn((ImageView)v.);
  8.                                 switch(bodypart){
  9.                                 case 1:
  10.                                         ds.setHorn(i);
  11.                                         break;
  12.                                 case 2:
  13.                                         ds.setHead(i);
  14.                                         break;
  15.                                 case 3:
  16.                                         ds.setBody(i);
  17.                                         break;
  18.                                 case 4:
  19.                                         ds.setLeftHand(i);
  20.                                         break;
  21.                                 case 5:
  22.                                         ds.setRightHand(i);
  23.                                         break;
  24.                                 case 6:
  25.                                         ds.setLegs(i);
  26.                                         break;
  27.                                 }
  28.                                 Intent i = new Intent(context.getApplicationContext(), Game.class);
  29.                                 context.startActivity(i);
  30.                         }} );  
  31.         }

In your main class declerate the imageviews and a DataStorage object:

  1. Context context=this;
  2. ImageView horn, head, leftarm, body, rightarm, leftarm, legs;
  3. DataStorage ds;
  4.  
  5. [...]
  6.  
  7. horn = (ImageView)findViewById(R.id.horn);
  8. head = (ImageView)findViewById(R.id.head);
  9. leftarm = (ImageView)findViewById(R.id.leftarm);
  10. rightarm = (ImageView)findViewById(R.id.rightarm);
  11. legs=(ImageView)findViewById(R.id.legs);

Then create array lists for body parts. For example the horn list:

  1. ArrayList<Integer> hornList=new ArrayList<Integer>();
  2.          hornList.add(R.drawable.horn1);
  3.          hornList.add(R.drawable.horn2);
  4.          hornList.add(R.drawable.horn3);
  5.          horn.setImageResource(hornList.get(ds.getHorns()));

Then you need to create an item selector class. It uses the itemselect.xml.

  1.  setContentView(R.layout.itemselect);

You should declerate the ArrayLists again in this class, and a DataStorage object.

In this case I used a simple switch-case statement to save the clicked item. Use the DataStore object's ClickListener method.

  1.         switch (bodypart){
  2.         case 1: //horn
  3.                 for (j=0;j<hornlist.size();j++){
  4.                         im.get(j).setImageResource(hornlist.get(j));
  5.                         if (j==0){
  6.                                 ds.ClickListener(im, 0, bodypart,  ds,context);
  7.                                
  8.                                
  9.                         }
  10.                         else if (j==1){
  11.                                 ds.ClickListener(im, 1, bodypart,  ds,context);
  12.                                
  13.                                
  14.                         }
  15.                         else if (j==2){
  16.                                 ds.ClickListener(im, 2, bodypart,  ds,context);    
  17.                                
  18.                                
  19.                         }
  20.                         else if (j==3){
  21.                                 ds.ClickListener(im, 3, bodypart,  ds,context);
  22.                        
  23.                         }
  24.                        
  25.                 }
  26.                 Toast.makeText(context, "Click the back button to show your robot", 3).show();
  27.                 break;
  28.         case 2:
  29.                 for (int j=0;j<headlist.size();j++){
  30.                         im.get(j).setImageResource(headlist.get(j));
  31.                         if (j==0){
  32.                                 ds.ClickListener(im, 0, bodypart,  ds,context);
  33.                                
  34.                                
  35.                         }
  36.                         else if (j==1){
  37.                                 ds.ClickListener(im, 1, bodypart,  ds,context);
  38.                
  39.                         }
  40.                         else if (j==2){
  41.                                 ds.ClickListener(im, 2, bodypart,  ds,context);                        
  42.                         }
  43.                         else if (j==3){
  44.                                 ds.ClickListener(im, 3, bodypart,  ds,context);
  45.                         }
  46.                 }
  47.                 Toast.makeText(context, "Click the back button to show your robot", 3).show();
  48.                 break;
  49.         case 3:
  50.                 for (int j=0;j<bodylist.size();j++){
  51.                         im.get(j).setImageResource(bodylist.get(j));
  52.                         if (j==0){
  53.                                 ds.ClickListener(im, 0, bodypart,  ds,context);
  54.                                
  55.                                
  56.                         }
  57.                         else if (j==1){
  58.                                 ds.ClickListener(im, 1, bodypart,  ds,context);
  59.                
  60.                         }
  61.                         else if (j==2){
  62.                                 ds.ClickListener(im, 2, bodypart,  ds,context);                        
  63.                         }
  64.                         else if (j==3){
  65.                                 ds.ClickListener(im, 3, bodypart,  ds,context);
  66.                         }
  67.                 }
  68.                 Toast.makeText(context, "Click the back button to show your robot", 3).show();
  69.                 break;
  70.         case 4:
  71.                 for (int j=0;j<leftarmlist.size();j++){
  72.                         im.get(j).setImageResource(leftarmlist.get(j));
  73.                         if (j==0){
  74.                                 ds.ClickListener(im, 0, bodypart,  ds,context);
  75.                                
  76.                                
  77.                         }
  78.                         else if (j==1){
  79.                                 ds.ClickListener(im, 1, bodypart,  ds,context);
  80.                
  81.                         }
  82.                         else if (j==2){
  83.                                 ds.ClickListener(im, 2, bodypart,  ds,context);                        
  84.                         }
  85.                         else if (j==3){
  86.                                 ds.ClickListener(im, 3, bodypart,  ds,context);
  87.                         }
  88.                 }
  89.                 Toast.makeText(context, "Click the back button to show your robot", 3).show();
  90.                 break;
  91.         case 5:
  92.                 for (int j=0;j<rightarmlist.size();j++){
  93.                         im.get(j).setImageResource(rightarmlist.get(j));
  94.                         if (j==0){
  95.                                 ds.ClickListener(im, 0, bodypart,  ds,context);
  96.                                
  97.                                
  98.                         }
  99.                         else if (j==1){
  100.                                 ds.ClickListener(im, 1, bodypart,  ds,context);
  101.                
  102.                         }
  103.                         else if (j==2){
  104.                                 ds.ClickListener(im, 2, bodypart,  ds,context);                        
  105.                         }
  106.                         else if (j==3){
  107.                                 ds.ClickListener(im, 3, bodypart,  ds,context);
  108.                         }
  109.                 }
  110.                 Toast.makeText(context, "Click the back button to show your robot", 3).show();
  111.                 break;
  112.         case 6:
  113.                 for (int j=0;j<legslist.size();j++){
  114.                         im.get(j).setImageResource(legslist.get(j));
  115.                         if (j==0){
  116.                                 ds.ClickListener(im, 0, bodypart,  ds,context);
  117.                                
  118.                                
  119.                         }
  120.                         else if (j==1){
  121.                                 ds.ClickListener(im, 1, bodypart,  ds,context);
  122.                
  123.                         }
  124.                         else if (j==2){
  125.                                 ds.ClickListener(im, 2, bodypart,  ds,context);                        
  126.                         }
  127.                         else if (j==3){
  128.                                 ds.ClickListener(im, 3, bodypart,  ds,context);
  129.                         }
  130.                        
  131.                 }
  132.                 Toast.makeText(context, "Click the back button to show your robot", 3).show();
  133.                 break;
  134.                
  135.         }

Thats it.. :)

Feel free to download the source code HERE. (Sorry for hungarian variable names :))

Comments

I think we need to bring more ideas for this purpose. Involvement of young people can be handy in this regard. I am happy to find a good post here. Bankruptcy attorneys

Cute robot. Thanks for the great tutorial on the app. And very kind to offer the link to the free download. Thanks! Coffee Lover

Very nice tutorial,love it!
signalsforex

Thanks for the information for the app. I always wondered what the code looked like to build these apps.Baju Muslim It's been an interest of mine to start doing some research and build some of these myself. Thanks for the article and letting me share

This post is beneficial and interesting. A lot of people will certainly assert that everything in your website is great. In the event you continue writing useful articles on your web site, often there is a greater possibility that a lot of website visitors will visit your web site. maid of honour speeches

That is a great point to bring up. I offer the thoughts above as general inspiration but clearly there are questions like the one you bring up where the most important thing will be working in honest good faith. I don?t know if best practices have emerged around things like that ironman gravity 4000 inversion table

the datagrid problem came up. My question is: I have to connect to a third party system which I can query with a specific language. The result is given back as a datatable with all the rows and columns. Can I connect/use this datatable as a datasource for the grid teeter hang ups ep 550 inversion table

I understood a third of the jokes. The Jerk, The Three Amigos and Parenthood are movies that I’ll stop and watch again, whenever I stumble upon them while channel surfing. His sublime performance in Baby Mama makes me thankful that he’s managed to keep up his acting along with his other passions. His diverse talents and interests have inspired me to consider a future where acting best inversion table

It's been an interest of mine to start doing some research and build some of these myself. Thanks for the article and letting me share.
5 door hatchback car

the contents you have mentioned.I wanted to thank you for this great article.I enjoyed every little bit part of it and I will be waiting for the new updates also so do post them floral duvet covers

This is a fantastic website and I can not recommend you guys enough. Full of useful resource and great layout very easy on the eyes. Please do keep up this great work. Medical Assistant

I was passing around and come across your site. It is wonderful. I mean as a content and design. I added you to my list and decided to spent the rest of the weekend Robert Pattison weight

There is an article that gives great insight to foundational elements when it comes to being able to successfully make money on the internet. Shizuko Leuhring

A friend of mine advised this site. And yes. it has some useful pieces of information and I enjoyed reading it. Therefore i would love to drop you a quick note to express my thanks. Take care
Riverside criminal defense attorney

What the hell am I doing? Developing a clothing game for Android...
Last time I was really bored, i tried to make a simple clothing game for android. cv

After that save the image using the 'Save for Web...' option. Here you should set every silice's settings

cl cm cn co cp cq cr cs ct cu

We can give them a good education that they can use in their life to get a better chance in this life. Im sure with a good education all of us will see the changing that all that kids can have. Nick Lighthill

Mais on peut rencontrer plusieurs modèles de housse pour ces valeureux smartphones. les écrins souples qui ne se vendent pas très cher et abritent le smartphone au strict minimum, les coques solides en plastique parfaitement efficaces contre les entailles et les luxueux fourreaux en cuir qui abritent totalement les iPhones avec une flexibilité hors pair notamment due au cuir qui le constitue. etui blackberry torch housse nokia n8 etui xperia x10 etui htc desire etui htc hero housse ipadCes housses en cuir fabriqués pour appareil mobile sont aussi disponibles avec un clapet rabattant qui permet de protéger totalement l’écran des heurts et griffures. De plus, leur maniabilité est souvent exceptionnelle. Mais il y a un contrecoup car ces étuis de luxe coûtent très cher mais comme le veut le dicton : la qualité, ça se paie. Tout d’abord, le fourreau doit parfaitement s’adapter à votre poche. housse iphone 4 housse ipad pochette iphone housse téléphone etui iphone housse mobile pochette iphone housse iphone 3gs etui samsung galaxy etui samsung wave Assurez-vous à côté de ça que l’écrin en plastique ne soit pas trop encombrant et ne vous gêne pas quand vous devez le prendre avec vous et lors de l’utilisation de votre téléphone portable. Ensuite, faites attention à ce que l’étui est composé une protection pour l’écran de votre mobile (c’est hautement préférable). Les étuis en cuir avec un clapet rabattant sont les plus adaptés pour cela. magazine chiot

Thanks for the information for the app. I always wondered what the code looked like to build these apps.
GSM Kampanya | Bilişim Teknoloji | Cep Telefonu | Turkcell Kampanyaları | Avea Kampanyaları | Vodafone Kampanyaları

I am very much pleased with the contents you have mentioned.I wanted to thank you for this great article.I enjoyed every little bit part of it and I will be waiting for the new updates also so do post them soon.

Well, I am so excited that I have found this your post because I have been searching for some information about it almost three hours. You helped me a lot indeed and reading this your article I have found many new and useful information about this subject. the diet solution program

Very good article, very usefull!!

Excellent read, I just passed this onto a colleague who was doing a little research on that. And he actually bought me lunch because I found it for him smile So let me rephrase that: Netbook Reviews

We can give them a good education that they can use in their life to get a better chance in this life. Im sure with a good education all of us will see the changing that all that kids can have. DVD Ripper For Mac

There is an article that gives great insight to foundational elements when it comes to being able to successfully make money on the internet. beertender b90

Companies these days are using ergonomic furniture to ensure that there are no injuries from work related hazards. Use an ergonomic chair and feel better comfort in your back and shoulder. rabattkod

Well, create clothing is definitely something new and can have fun while doing it, don't you think so? search engine optimization services social media Not necessary something bore, people like weird thing too : )

^_^. it's really funny. you can make it can more

This looks interesting, but I'd like to see the app do more than this. I'm not really interested in styling up an alien, now if you made it use cat jewelry, that might be another story.

Clothing? Haha, intresting app idea... Takes me too much time to do one of these apps I have to make sure it's something I'll really use a lot :P

vitamin b12 benefits

Nice App, is it finished yet? Can you set the dressed android as wallpaper? That would be pretty cool.
seo services whitehat seo

Thanks for the information for the app. I always wondered what the code looked like to build these apps. It's been an interest of mine to start doing some research and build some of these myself. Thanks for the article and letting me share. Low-E