In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
这篇"Android怎么实现数独游戏开发"文章的知识点大部分人都不太理解,所以小编给大家总结了以下内容,内容详细,步骤清晰,具有一定的借鉴价值,希望大家阅读完这篇文章能有所收获,下面我们一起来看看这篇"Android怎么实现数独游戏开发"文章吧。
一、界面布局
1.主界面
2.数字键盘布局
3.游戏提示布局
二、游戏提示类
package com.dw.gamesuduku;import android.app.Activity;import android.os.Bundle;public class About extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.about); }}
三、逻辑实现1
package com.dw.gamesuduku;import android.app.Activity;import android.app.Dialog;import android.os.Bundle;import android.util.Log;import android.view.Gravity;import android.widget.Toast;public class Game extends Activity { private static final String TAG="Sudoku"; private static final String PREF_PUZZLE="puzzle"; protected static final int DIFFICULTY_CONTINUE=-1; public static final String KEY_DIFFICULTY="difficulty"; public static final int DIFFICULTY_EASY=0; public static final int DIFFICULTY_MEDIUM=1; public static final int DIFFICULTY_HARD=2; private int puzzle[]=new int[9*9]; private PuzzleView puzzleView; //三种游戏模式 private static final String easyPuzzle="360000000004230800000004200"+ "070460003820000014500013010"+ "001900000007048300000000045"; private static final String mediumPuzzle="650000070000506000014000005"+ "007009000002314700000700800"+ "500000630000201000030000097"; private static final String hardPuzzle="009000000080605020501078000"+ "000000700706040102004000000"+ "000720903090301080000000600"; private final int used[][][]=new int[9][9][]; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); Log.e(TAG, "onCreate"); int diff=getIntent().getIntExtra(KEY_DIFFICULTY, DIFFICULTY_EASY); puzzle=getPuzzle(diff); calculateUsedTiles(); puzzleView=new PuzzleView(this); setContentView(puzzleView); puzzleView.requestFocus(); //if the activity is restarted ,do a continue next time getIntent().putExtra(KEY_DIFFICULTY, DIFFICULTY_CONTINUE); } @Override protected void onPause() { // TODO Auto-generated method stub super.onPause(); Music.stop(this); //Save the current puzzle getPreferences(MODE_PRIVATE).edit().putString(PREF_PUZZLE, toPuzzleString(puzzle)).commit(); } @Override protected void onResume() { // TODO Auto-generated method stub super.onResume(); Music.play(this, R.raw.game); } protected int[] getUsedTiles(int x,int y){ return used[x][y]; } private void calculateUsedTiles() { // TODO Auto-generated method stub for (int x = 0; x < 9; x++) { for (int y = 0; y < 9; y++) { used[x][y]=calculateUsedTiles(x,y); } } } private int[] calculateUsedTiles(int x, int y) { // TODO Auto-generated method stub int c[]=new int[9]; //horizontal for(int i=0;i
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.