Android realizes crazy continuous viewing of game loading interface pictures and game activity (4)

As you can see in the article "my advanced journey to Android -- > state data model of Android crazy game implementation (III)", in the abstractboard code, when the program needs to create N piece objects, the program will directly call the getplayimages() method of imageutil to obtain pictures, and this method will randomly obtain n pictures from the RES / drawable directory.

The following is the RES / drawable directory view:

In order to enable getplayimages() method to randomly obtain n pictures from RES / drawable directory, the specific implementation is divided into the following steps:

Here is the code of imageutil class: cn \ oyp \ link \ utils \ imageutil.java

The layout file of the game interface has been given earlier. The layout file needs an activity to display. In addition, the activity also needs to provide event listeners for the events of the buttons and gameview components of the game interface. Especially for the gameview component, the program needs to monitor the user's touch action. When the user touches the screen, the program needs to obtain which box the user touches and judge whether to "eliminate" the box. In order to determine whether to eliminate the block, the program needs to make the following judgment:

If the program has selected a block before, judge whether the currently touched block can be "connected" with the previous block. If it can be connected, eliminate two blocks; If it cannot be connected, set the current box as the selected box.

If the program has not checked the box before, directly set the current box as the checked box.

Here is the code of activity: cn \ oyp \ link \ linkactivity.java

The activity uses two classes, which will be described in the next blog. Gameconf: responsible for managing the initialization setting information of the game. Gameservice: responsible for the logical implementation of the game.

For specific implementation steps, please refer to the following link:

My advanced journey of Android ------ > preview of the game effect of Android crazy game (I)

My advanced journey of Android ------ > Android crazy watch the implementation of the game and develop the game interface (2)

My advanced journey of Android ------ > Android crazy continuous watching of the implementation state data model of the game (3)

My android advanced journey ------ > Android crazy watch game implementation game logic (5)

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>