Android puzzles-transformers and android puzzles

Source: Internet
Author: User

Android puzzles-transformers and android puzzles
Opening

After learning Android development for a few months, I made a simple jigsaw puzzle game. I didn't use the game framework, and the name was purely entertaining. If it was rough, please give it a smile.

The game interface is a 6*6 small image cut by an image, and one of them is taken away. The player passes the game by returning all the small images to the correct position through different operations, operations that players can perform are:

    • The rows and columns of the empty rows can both move up and down, and (2, 3) are empty, so all the pictures in the first row can move left and right, for example, moving (2, 0) to the right, then (), () will shift to the right, and () will become vacant. Same Column position
    • If one row has no space available, this line can be rotated left and right. For example, if it is rotated to the right, all the small images will move to the right, and the images on the right will move to the left.

There is a picture of the truth. The following is the first two levels. I got the hero of the two rankus qingtianzhu and Wei zhentian. I tried it myself, but it took too much time, so I wrote a menu function to restore it with one click.

Game Implementation ideas

Display overflowmenu // set to display the overflow button // sHasPermanentMenuKey is used to determine whether the mobile phone has a physical Menu key. After Android 3.0, the mobile phone can have no physical menu private void setOverflowShowingAlways () {try {ViewConfiguration config = ViewConfiguration. get (this); Field menuKeyField = ViewConfiguration. class. getDeclaredField ("sHasPermanentMenuKey"); menuKeyField. setAccessible (true); menuKeyField. setBoolean (config, false);} catch (Exception e) {e. printStackTrace ();}}

 

Menu command public boolean onOptionsItemSelected (MenuItem item) {// Handle action bar item clicks here. the action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest. xml. int id = item. getItemId (); if (id = R. id. help) {LinearLayout layout = (LinearLayout) getLayoutInflater (). inflate (R. layout. help_layout, null); ImageView imageVie W = (ImageView) layout. findViewById (R. id. helpView); imageView. setImageResource (transformers. get (currentIndex ). getDrawableId (); AlertDialog. builder helpDialogBuilder = new AlertDialog. builder (this); final AlertDialog helpDialog = helpDialogBuilder. create (); imageView. setOnClickListener (new View. onClickListener () {@ Override public void onClick (View view) {helpDialog. dismiss () ;}}); helpDialog. sh Ow (); helpDialog. setContentView (layout);} if (id = R. id. about) {final AlertDialog. builder aboutDialogBuilder = new AlertDialog. builder (this); aboutDialogBuilder. setNegativeButton ("return", new DialogInterface. onClickListener () {@ Override public void onClick (DialogInterface dialogInterface, int I) {dialogInterface. dismiss () ;}}); AlertDialog aboutDialog = aboutDialogBuilder. setTitle ("about Transformers "). set Message ("the image is from the network. If there is any infringement, please contact \ r \ n developer: sentinel \ r \ n" + "QQ :**********"). create (); aboutDialogBuilder. show () ;}// used for testing. When you click the ActionBar test menu, the image is automatically displayed at the next level/* if (id = R. id. test) {List <Button> list = new ArrayList <Button> (); for (int I = 0; I <ROW; I ++) for (int j = 0; j <COL; j ++) {list. add (grid [I] [j]);} for (Button btn: list) {if (btn! = Null) {grid = new Button [ROW] [COL]; int row = btn. getId ()/ROW; int col = btn. getId () % ROW; grid [row] [col] = btn; absoluteLayout. removeView (btn); addButtonLayout (btn, row, col) ;}} */return super. onOptionsItemSelected (item );}

 


How can I complete a puzzle in an android puzzle game?

Specify an attribute for each image and store its location identifier. When all the Image Location identifiers meet the victory condition, the puzzle is completed.

Love picture every day for Transformers puzzles

Ever-changing!
Hope to help you
 

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.