运用andrid最基础的sufaceView制作小时候的最爱,水果老虎机过程文档

先来张初始效果图,图片全部来在网络扣图,那个累呀.........

整个图型的画法,和转灯的画法

// 自定义画法private void drawView() {try {if (sh != null) {iCanvas = sh.lockCanvas();// 获取画布// 设置画笔和位图没有锯齿iCanvas.setDrawFilter(new PaintFlagsDrawFilter(0,Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG));// 背景bgiCanvas.drawBitmap(bitmap_bg, null, new RectF(0, 0,screenWidth, screenHeight), null);// 得分条-winiCanvas.drawBitmap(bitmap_score_win, null, new RectF(margin, 0,margin + checkWidth * 3, checkWidth), null);iCanvas.drawText("" + winOddsScore,margin + checkWidth * 3 - 5, checkWidth - checkWidth/ 7, iPaint_score);// 现在分数条-creditiCanvas.drawBitmap(bitmap_score_credit, null, new RectF(margin+ checkWidth * 4, 0, margin + checkWidth * 7,checkWidth), null);iCanvas.drawText("" + creditNum, margin + checkWidth * 7 - 5,checkWidth - checkWidth / 7, iPaint_score);//画top正方型for (int i = 0; i < 7; i++) {RectF rectTop = new RectF(margin + i * checkWidth,checkWidth, margin + checkWidth + i * checkWidth,checkWidth + checkWidth);iCanvas.drawBitmap(Content.getTopBitmaps()[i], null,rectTop, null);}// 画right正方型for (int i = 1; i < 6; i++) {RectF rectRight = new RectF(margin + checkWidth * 6, i* checkWidth + checkWidth, margin + checkWidth * 7,checkWidth + i * checkWidth + checkWidth);iCanvas.drawBitmap(Content.getRightBitmaps()[i - 1], null,rectRight, null);}// 画bottom正方型for (int i = 0; i < 7; i++) {RectF rectBottom = new RectF(margin + i * checkWidth,checkWidth * 6 + checkWidth, margin + checkWidth+ i * checkWidth, checkWidth * 7+ checkWidth);iCanvas.drawBitmap(Content.getBottomBitmaps()[i], null,rectBottom, null);}// 画left正方型for (int i = 1; i < 6; i++) {RectF rectLeft = new RectF(margin, i * checkWidth+ checkWidth, margin + checkWidth, checkWidth + i* checkWidth + checkWidth);iCanvas.drawBitmap(Content.getLeftBitmaps()[i - 1], null,rectLeft, null);}// 移动的发光图标if (isOk) {if (num < randomNum) {// 每次刷屏num+1;当比随机出来的转数小时,继续转,当大于等于时就停止if (num < (randomNum / 13)) {// 控件转灯的速度,由慢-快-慢sleepNum = 300;} else if (num < (randomNum * 2 / 13)) {sleepNum = 200;} else if (num < (randomNum * 3 / 13)) {sleepNum = 100;} else if (num < (randomNum * 4 / 13)) {sleepNum = 80;} else if (num < (randomNum * 5 / 13)) {sleepNum = 50;} else if (num < (randomNum * 6 / 13)) {sleepNum = 20;} else if (num < (randomNum * 7 / 13)) {sleepNum = 10;} else if (num < (randomNum * 8 / 13)) {sleepNum = 20;} else if (num < (randomNum * 9 / 13)) {sleepNum = 50;} else if (num < (randomNum * 10 / 13)) {sleepNum = 80;} else if (num < (randomNum * 11 / 13)) {sleepNum = 100;} else if (num < (randomNum * 12 / 13)) {sleepNum = 200;} else {sleepNum = 300;}if (num % 1 == 0) {if (num < randomNum - 1) {//最后一下声响(啪)的一声soundPool.play(dingSound, 1, 1, 1, 0, 1);} else if (isPaSound) {soundPool.play(paSound, 1, 1, 1, 0, 1);isPaSound = false;}if (countTop < 7) {rectSelect = new RectF(margin + countTop* checkWidth, checkWidth, margin+ checkWidth + countTop * checkWidth,checkWidth + checkWidth);iCanvas.drawBitmap(bitmap_sifangkuang, null,rectSelect, null);countTop++;} else if (countTop >= 7 && countRight < 6) {rectSelect = new RectF(margin + 6 * checkWidth,countRight * checkWidth + checkWidth,margin + checkWidth * 7, checkWidth+ countRight * checkWidth+ checkWidth);iCanvas.drawBitmap(bitmap_sifangkuang, null,rectSelect, null);countRight++;} else if (countRight >= 6 && countBottom >= 0) {rectSelect = new RectF(margin + countBottom* checkWidth, checkWidth * 6+ checkWidth, margin + checkWidth+ countBottom * checkWidth, checkWidth* 7 + checkWidth);iCanvas.drawBitmap(bitmap_sifangkuang, null,rectSelect, null);countBottom--;} else if (countBottom < 0 && countLeft > 0) {rectSelect = new RectF(margin, checkWidth* countLeft + checkWidth, margin+ checkWidth, checkWidth * countLeft+ checkWidth + checkWidth);iCanvas.drawBitmap(bitmap_sifangkuang, null,rectSelect, null);countLeft--;}if (countLeft == 0) {// 循环一圈,以左上角0,0为始点countTop = 0;countRight = 1;countLeft = 5;countBottom = 6;}}num++;//通过自加,接近随机出来的转运数值} else {//最后停的一下iCanvas.drawBitmap(bitmap_sifangkuang, null,rectSelect, null);float x = rectSelect.left;float y = rectSelect.top;// 赔率// intBar+intSeven+intStar+intXG+intLD+intMG+intOrange+intAppleif (isScore) {//自定义方法,获取中奖分数winOddsScore = Content.getWinOdds(intBar, intSeven,intStar, intXG, intLD, intMG, intOrange,intApple, margin, checkWidth, x, y);}//System.out.println("中奖分数=" + winOddsScore);if (isStart) {// 按了go开始进入if (winOddsScore == 0) {//没中奖,清0cleanAllNum();}}isStart = false;sleepNum = 100;//运气run的sleep时间}}RectF rectBottom_1 = new RectF(margin, checkWidth * 7+ checkWidth, screenWidth - margin, checkWidth * 8+ checkWidth);iCanvas.drawBitmap(bitmap_bottom_1, null, rectBottom_1, null);RectF rectBottom_2 = new RectF(margin, checkWidth * 8+ checkWidth, screenWidth - margin, checkWidth * 8+ checkWidth / 2 + checkWidth);// iCanvas.drawBitmap(bitmap_bottom_2, null, rectBottom_2,// null);RectF rectBottom_3 = new RectF(margin, checkWidth * 9+ checkWidth / 2, screenWidth - margin, checkWidth * 11);iCanvas.drawBitmap(bitmap_bottom_3, null, rectBottom_3, null);iCanvas.drawText(stringBar, margin + chipNumWidth / 4,checkWidth * 8 + checkWidth * 2 / 5 + checkWidth,iPaint);iCanvas.drawText(stringSeven, margin + chipNumWidth+ chipNumWidth / 5, checkWidth * 8 + checkWidth * 2 / 5+ checkWidth, iPaint);iCanvas.drawText(stringStar, margin + chipNumWidth * 2+ chipNumWidth / 5, checkWidth * 8 + checkWidth * 2 / 5+ checkWidth, iPaint);iCanvas.drawText(stringXG, margin + chipNumWidth * 3+ chipNumWidth / 6, checkWidth * 8 + checkWidth * 2 / 5+ checkWidth, iPaint);iCanvas.drawText(stringLD, margin + chipNumWidth * 4+ chipNumWidth / 6, checkWidth * 8 + checkWidth * 2 / 5+ checkWidth, iPaint);iCanvas.drawText(stringMG, margin + chipNumWidth * 5+ chipNumWidth / 6, checkWidth * 8 + checkWidth * 2 / 5+ checkWidth, iPaint);iCanvas.drawText(stringOrange, margin + chipNumWidth * 6+ chipNumWidth / 7, checkWidth * 8 + checkWidth * 2 / 5+ checkWidth, iPaint);iCanvas.drawText(stringApple, margin + chipNumWidth * 7,checkWidth * 8 + checkWidth * 2 / 5 + checkWidth,iPaint);}} catch (Exception e) {} finally {if (iCanvas != null) {sh.unlockCanvasAndPost(iCanvas);// 解锁画布并提交}}}

自定义获取中奖分数的方法

//传进来中奖的坐标,返回中奖的赔率和中奖的水果public static int getWinOdds(int intBar,int intSeven,int intStar,int intXG,int intLD,int intMG,int intOrange,int intApple,float margin,float checkWidth,float x,float y){
//      System.out.println("intBar="+intBar);
//      System.out.println("intSeven="+intSeven);int winOdds[] = new int[2];int winOddsScroe = 0;if(y==checkWidth){//topswitch ((int)((x-margin)/checkWidth)) {case 0:winOdds[0] = 10;winOdds[1] = 1;break;case 1:winOdds[0] = 20;winOdds[1] = 3;break;case 2:winOdds[0] = 25;winOdds[1] = 7;break;case 3:winOdds[0] = 50;winOdds[1] = 7;break;case 4:winOdds[0] = 5;winOdds[1] = 0;break;case 5:winOdds[0] = 2;winOdds[1] = 0;break;case 6:winOdds[0] = 15;winOdds[1] = 2;break;default:break;}}if((x-margin)/6==checkWidth){switch ((int)(y/checkWidth)) {case 2:winOdds[0] = 20;winOdds[1] = 4;break;case 3:winOdds[0] = 2;winOdds[1] = 4;break;case 4:winOdds[0] = -1;winOdds[1] = -1;break;case 5:winOdds[0] = 5;winOdds[1] = 0;break;case 6:winOdds[0] = 2;winOdds[1] = 1;break;default:break;}}if(y==checkWidth*7){switch ((int)((x-margin)/checkWidth)) {case 0:winOdds[0] = 15;winOdds[1] = 2;break;case 1:winOdds[0] = 2;winOdds[1] = 2;break;case 2:winOdds[0] = 5;winOdds[1] = 0;break;case 3:winOdds[0] = 40;winOdds[1] = 6;break;case 4:winOdds[0] = 2;winOdds[1] = 6;break;case 5:winOdds[0] = 20;winOdds[1] = 3;break;case 6:winOdds[0] = 10;winOdds[1] = 1;break;default:break;}}if(x==margin){switch ((int)(y/checkWidth)) {case 2:winOdds[0] = 2;winOdds[1] = 3;break;case 3:winOdds[0] = 5;winOdds[1] = 0;break;case 4:winOdds[0] = -2;winOdds[1] = -2;break;case 5:winOdds[0] = 2;winOdds[1] = 5;break;case 6:winOdds[0] = 30;winOdds[1] = 5;break;default:break;}}//intBar+intSeven+intStar+intXG+intLD+intMG+intOrange+intAppleswitch (winOdds[1]) {case 0:winOddsScroe = intApple * winOdds[0];break;case 1:winOddsScroe = intOrange * winOdds[0];break;case 2:winOddsScroe = intMG * winOdds[0];break;case 3:winOddsScroe = intLD * winOdds[0];break;case 4:winOddsScroe = intXG * winOdds[0];break;case 5:winOddsScroe = intStar * winOdds[0];break;case 6:winOddsScroe = intSeven * winOdds[0];break;case 7:winOddsScroe = intBar * winOdds[0];break;default:break;}return winOddsScroe;}

暂时做到这,实现了压注,开始游戏,中奖获取分数,暂时不能重复上次的压注,每运行一次,都会把压注和得分清0

还没有做赌大小等功能

android 水果老虎机 文档一相关推荐

  1. 使用android SDk帮助文档(英文) 下载中文SDK帮助文档(中文)

    2019独角兽企业重金招聘Python工程师标准>>> 其实android sdk本身里面包含了很多开发帮助文档(英文版).具体的使用步骤如下 1.打开sdk下载帮助文档目录 我的安 ...

  2. android 英文帮助文档地址,使用android SDk帮助文档(英文) 下载中文SDK帮助文档(中文)...

    其实android sdk本身里面包含了很多开发帮助文档(英文版).具体的使用步骤如下 1.打开sdk下载帮助文档目录 我的安装目录在 C:\Program Files\Android\android ...

  3. android Word 显示文档结构图

    今天,简单讲讲android里浏览Word文档时,如何显示文档的文档结构图. 这个其实也很简单,之前我把自己用WPS写成的文档发送给领导查看,他用的是Word查看的文档,所以没有显示我在WPS上设置的 ...

  4. CTS(16 )---Android 兼容性定义文档

    Android 兼容性定义文档 欢迎阅读 Android 兼容性定义文档 (CDD).本文档列举了设备需要满足哪些要求才能与最新的 Android 版本兼容.为了与 Android 兼容,设备实现必须 ...

  5. 微博Android平台SDK文档

    博Android平台SDK文档 编号:WEIBO_ANDROID_SDK 版本:WEIBO_ANDROID_SDK V3.1.2 修订记录: 时间 文档版本 修订人 备注 2012/7/20 2.0. ...

  6. android pdfview 显示目录,Android 查看pdf文档——PDFView

    最近在搞Android显示word文档跟pdf文档的显示,分享一个显示pdf文档的小Demo(ps:word文档的显示网上挺多的).   这里使用的是PDFView,是GitHub上面的一个开源项目点 ...

  7. Android 查看pdf文档——PDFView

    最近在搞Android显示word文档跟pdf文档的显示,分享一个显示pdf文档的小Demo(ps:word文档的显示网上挺多的). 这里使用的是PDFView,是GitHub上面的一个开源项目点击查 ...

  8. android 离线帮助文档

    API是开发者必备的工具,就像一本专业的大辞典一样,你能从其中找到所有相关开发中遇到的问题.只是 由于公司的催进度或者个人的懒惰,往往依赖于百度或者谷歌等网络搜索来解决问题,从而忽视了API文档的阅读 ...

  9. android 开放平台开发,OPPO开放平台上线Android 12适配文档

    OPPO 近日悄然在开放平台添加了 Android 12 适配文档,该文档可帮助 App 开发者更好地兼容 Android 12. 虽然文档内还没有任何内容,但这标志着 OPPO 已经开始了 Andr ...

  10. android制作开放平台,OPPO 开放平台上线 Android 12 适配文档

    IT之家 5 月 17 日消息OPPO 近日悄然在开放平台添加了 Android 12 适配文档,该文档可帮助 App 开发者更好地兼容 Android 12. 虽然文档内还没有任何内容,但这标志着 ...

最新文章

  1. Codeforces Gym 100650B Countdown (离线)
  2. 机器学习知识点(三十五)蒙特卡罗方法
  3. v-show 与 v-if 的区别
  4. 大数运算(6)——大数阶乘(求位数)
  5. access labsql 出错_一段由ACCESS转为SQL SERVER后出现的CINT错误
  6. 【UML】交互建模中交互图允许的消息类型
  7. javascript闭包_JavaScript闭包基本指南
  8. 【彻底搞清楚javascript中的require、import和export 】
  9. Uva 11218 - KTV
  10. 地图小部件—ArcGIS API for JavaScript
  11. linux 创建交换文件格式,Linux系统下的交换分区和交换文件的含义 (创建交换分区文件基本文件的swap)...
  12. python可视化界面开发实例-Python可视化界面编程入门
  13. ueditor清除多余空行
  14. 英伟达驱动更新记录_手把手教你如何通过NVIDIA(英伟达显卡)官网及时更新升级显卡驱动程序版本-网络教程与技术 -亦是美网络...
  15. linux 安装Elasticsearch
  16. 新建参考线快捷键,透视快捷键
  17. 【Volume X has invalid topology for mapped brick meshing】
  18. 奇葩需求系列-距离明天十二点倒计时
  19. 51nod 1278 相离的圆 二分+排序
  20. python制作图表(爬取数据之后分析最后制成图表)

热门文章

  1. Python入门程序【八】
  2. action mutation 调用_浅谈vuex之mutation和action的基本使用
  3. 饥荒steam服务器文档,Steam联机饥荒服务器搭建
  4. 79.输入子系统(上)
  5. 智能硬件「卖多少」才不算贵?
  6. BMS的过压、过流、欠压是如何产生的-笔记随笔
  7. Dance Your PhD,你想过用舞蹈展示你的博士课题吗?
  8. Java中的常用类——StringBuffer
  9. CSR8670项目实战:BlueCar蓝牙音频网关
  10. TiDB体系结构之TiDB Server