Development Process and experiences of the Android bunny hop Bell game

Source: Internet
Author: User

The Android game development example in this article is shared by a relatively self-motivated student, implementing a little rabbit-jumping Bell game. The author has experience and doubts during the development process. You can post your own comments accordingly.

I. Game Running Effect

 

Ii. Running Environment Description

I useEclipseDeveloped and run on the simulator. The simulator configuration is as follows. Note that in the Skin option, Built-in must be "WQVGA400", which is a defect of my game ).

Iii. Architecture Description

Before reading this part, I suggest you go to the Internet to play that small game http://www.vifo.com.cn/games/no2/tiaolindang/tiaolindang.swf), I believe you will be helpful to my understanding of the class.

The following is Eclipse, which briefly describes the functions of each class:

1. RabitActivity: The game is started from this Activity. Its main function is to display the game introduction IntroduceView), how to play HelpView), and whether to enable sound AudioView) these three different screens.

2. GameActivity: After you select whether to enable the sound effect, switch to a new activity, that is, GameActivity.

3. Rabit, Bell, and Bird define rabbits, bells, and birds in the game. Including state, bitmaps, and speed. I feel that state is a very important attribute. It determines the state of the object and draws different images based on these States.

4. GameSurfaceView: The display class of the game. It is also a large container that includes all the objects in the game. The update_all_components () is the core of the game.

5. BellCreator: responsible for creating Bell objects. When a bell disappears from the screen, the object is not destroyed, but recycled by BellCreator. When a new bell crashes on the screen next time, bellCreator re-initializes the recycled Bell object and submits it to GameSurfaceView. The purpose is to save resources and improve system performance.

6. Background: generates a dynamic Background.

7. AudioProvider: audio encapsulation, responsible for sound effects.

So how does the entire game run and all object images?

I believe some people with experience in Game Development know that in the whole system, apart from the main thread, another thread will be started. This thread is responsible for constantly refreshing the status of all objects and updating images, to achieve the animation effect.

I did the same. In GameSurfaceView, I have an internal class, RefurbishThread, which calls the GameSurfaceView. update_all_components () method every 100 milliseconds to update all rabit, bell, bird, and background states, and then redraws the screen.

The source code of the entire program can be downloaded at http://www.rayfile.com/files/f8b99ad1-c4e8-11e0-bb73-0015c55db73d.

I personally think that the definition of Rabit, Bell, and other object states is a bit of a headache. I am not doing well enough. Below are some states of Rabit:

 
 
  1. Private int face_state;
  2. Private int ground_state;
  3. Private int air_state;
  4. // Right-left rabit
  5. Public static final int RABIT_FACE_LEFT = 1;
  6. Public static final int RABIT_FACE_RIGHT = 2;
  7. // Rabit is in the ground
  8. Public static final int RABIT_NOT_ON_GROUND = 0;
  9. Public static final int RABIT_LEFT_STOP = 1;
  10. Public static final int RABIT_RIGHT_STOP = 2;
  11. Public static final int rabit_left_movepolicon_ground = 3;
  12. Public static final int RABIT_LEFT_MOVE2_ON_GROUND = 4;
  13. Public static final int rabit_right_movepolicon_ground = 5;
  14. Public static final int RABIT_RIGHT_MOVE2_ON_GROUND = 6;
  15. // Rabit status in the air
  16. Public static final int RABIT_ON_AIR_UP0 = 0;
  17. Public static final int RABIT_ON_AIR_UP1 = 1;
  18. Public static final int RABIT_ON_AIR_UP2 = 2;
  19. Public static final int RABIT_ON_AIR_UP3 = 3;
  20. Public static final int RABIT_ON_AIR_UP4 = 4;
  21. Public static final int RABIT_ON_AIR_UP5 = 5;
  22. Public static final int RABIT_ON_AIR_STOP = 6;
  23. Public static final int RABIT_ON_AIR_DOWN = 7;

4. Little technical experience

The following are some technical aspects of development, and I hope to help you:

1. How to maintain horizontal display of the game screen without automatically switching the display mode because of the mobile phone portrait: add these two attributes in the activity tag to android: screenOrientation = "landscape" android: configChanges = "orientation | keyboardHidden | navigation"

 
 
  1. <activity androidandroidandroid:name=".GameActivity"android:screenOrientation="landscape"  android:configChanges="orientation|keyboardHidden|navigation"></activity>   

2. Differences between android development drawable (hdpi, mdpi, ldpi:

Http://hi.baidu.com/lujie_dream/blog/item/4ed68b77b28a84210cd7da97.html

3. Basic knowledge of java threads

Http://java.chinaitlab.com/line/373702.html

4. Handler usage

Http://www.pin5i.com/showtopic-android-handler.html

5. My confusion

1. I don't know how regular Android game development works. Isn't it as simple as creating images like me? Is it a game engine? What engine? I feel that there are too few materials on the Internet. I hope google can provide more help in this regard. I don't know whether the column watching officer knows how to develop a real mobile game. I am very grateful for your advice.

2. The architecture is poor, and the coupling between classes is high and scary. Although I took the design model course last semester, it may be difficult to learn. This mini-game is useless. I think, isn't the design pattern very useful for small projects? Maybe it is normal for a small project to have great coupling. Does it need to separate many modules and design them separately? The design mode may be very useful for large projects, and the design mode is also required for large projects. I don't know if my thoughts are correct. I hope you can give me some advice.

Vi. Overall perception

Experience on the Android Development Platform:

I have a superficial feeling that development on the Android platform is not very different from normal Java development. In addition to processing configuration files, most of the code of the program is written in Java. If you have learned Java and have a little Java development experience, you can get started with Android very quickly. Read books, check information on the Internet, get familiar with some basic mechanisms, such as Activity, learn about some APIs, and try again. It is quite easy to get started. Of course, the ignorant are fearless. Presumably, some deep-layer Android mechanisms are not that simple. There are still many concepts that I have not mastered on Android, so I must learn them carefully. What I want to talk about is that it is not that difficult to be an Android cainiao. So if you are interested in Android development, take action ~

Persistence:

Persistence is not easy.

I learned about Android and started with high enthusiasm. reading books and watching videos is quite good. I am very happy to learn about it every day.

Many difficulties have been encountered during actual development. It is mainly about the overall and detailed design of the game. Similar games have very few references. Many Class definitions need to be easily understood. No one can discuss them together, and they feel that they cannot solve the problem and it is very painful! Very stunned! Very lost! So I want to give up. I have no hard requirements for my own work. Why should I be difficult to do it for myself?

At ordinary times, I always despise those who advocate perseverance in the book and think that they are nothing remarkable. They are not just persistence, but may be fabricated by future generations. But now, let's look at myself. If I give up, What qualifications do I have to look down on others? Therefore, in this kind of psychology, I had a hard head to continue learning. Oh, of course, I am also indulging myself, playing hard, and then learning to develop.

In short, I can say that although it is easy for others to do this little thing, you may despise me, but I don't care, I survived, and now I am in a good mood.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.