扫雷android源代码,Android实现扫雷小游戏

本文实例为大家分享了Android实现扫雷小游戏的具体代码,供大家参考,具体内容如下

先看效果图:

初始游戏界面:

202011161139381.png

翻开块和标记块界面:

202011161139382.png

游戏结束界面:

202011161139383.png

菜单界面:

202011161139384.png

更换难度界面:

202011161139385.png

查看游戏记录界面:

202011161139386.png

代码分析

Block.java

这部分代码实现的是游戏界面的板块

设置四个变量来记录当前块是否被翻开,当前块是否是地雷,是否把当前快标记为地雷(也就是插旗子),当前块周围的地雷数量。

关键部分代码:

//设置翻开状态

public void setNumberOfSurroundingMines(int number) {

this.setBackgroundResource(R.drawable.selected);//设置翻开背景图

updateNumber(number);//设置周围雷数

}

//添加雷块标识

public void setMineIcon() {

this.setBackgroundResource(R.drawable.dl);

}

//

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
安卓 扫雷源码 添加重新开始按钮支持 Android studio ====================================== Risky Project Location: ----------------------- The tools *should* handle project locations in any directory. However, due to bugs, placing projects in directories containing spaces in the path, or characters like ", ' and &, have had issues. We're working to eliminate these bugs, but to save yourself headaches you may want to move your project to a location where this is not a problem. D:\Program Files\android_s_workplace\terrysaolei - Ignored Files: -------------- The following files were *not* copied into the new Gradle project; you should evaluate whether these are still needed in your project and if so manually move them: * ic_launcher-web.png * proguard-project.txt Moved Files: ------------ Android Gradle projects use a different directory structure than ADT Eclipse projects. Here's how the projects were restructured: * AndroidManifest.xml => app\src\main\AndroidManifest.xml * assets\ => app\src\main\assets * res\ => app\src\main\res\ * src\ => app\src\main\java\ Next Steps: ----------- You can now build the project. The Gradle project needs network connectivity to download dependencies. Bugs: ----- If for some reason your project does not build, and you determine that it is due to a bug or limitation of the Eclipse to Gradle importer, please file a bug at http://b.android.com with category Component-Tools. (This import summary is for your information only, and can be deleted after import once you are satisfied with the results.)

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值