2020征文-手表鸿蒙HarmonyOS小游戏十二生肖之找到那只猪及上架

开发 前端 OpenHarmony
那天在论坛里看到张荣超老师发了一个2048的游戏,后面就想到自己用2048的玩法写个十二生肖主题的消消乐的游戏写着玩玩。

想了解更多内容,请访问:

51CTO和华为官方合作共建的鸿蒙技术社区

https://harmonyos.51cto.com/#zz

前言

那天在论坛里看到张荣超老师发了一个2048的游戏,后面就想到自己用2048的玩法写个十二生肖主题的消消乐的游戏写着玩玩。在官方文档中看到有HarmonyOS上架相关的文档,并体验了下上架流程(PS:11月18号提交的上架现在都没有审核反馈,如果不让上其实官方可以打回的。)

代码一直放着今天看到有征文有奖所以才想到发上来。

基本布局


页面还是用宫格布局,上方文字显示当前动物,宫格显示动物图片。

  1. <div ontouchstart="touchStart" ontouchend="touchEnd" class="container"
  2.     <div class="zoon"
  3.         <text> 
  4.             {{zoon}} 
  5.         </text> 
  6.     </div> 
  7.     <stack class="wins" ref="wins"
  8.         <canvas id="cantx" ref="canvas" class="cantx" focusable="true" ></canvas> 
  9.     </stack> 
  10.     <input type="button" value="重新开始" class="btn" onclick="reset"/> 
  11. </div> 
  12.  
  13. /* index.css */ 
  14. .container { 
  15.     flex-direction: column
  16.     width: 90%; 
  17.     height: 90%; 
  18.     background-color: black; 
  19.  
  20.  
  21. .wins{ 
  22.     width: 290px; 
  23.     height: 290px; 
  24.     margin-left: 80px; 
  25.     margin-top: 80px; 
  26.  
  27. .cantx{ 
  28.     width: 290px; 
  29.     height: 290px; 
  30.  
  31. .btn { 
  32.     width: 175px; 
  33.     height: 50px; 
  34.     background-color: #AD9D8F; 
  35.     font-size: 24px; 
  36.     margin-top: 10px; 
  37.     margin-left: 140px; 
  38.  
  39. .zoon { 
  40.     position: absolute
  41.     margin-left: 200px; 
  42.     font-size: 18px; 
  43.     text-align: center; 
  44.     width: 100px; 
  45.     height: 50px; 
  46.     margin-top: 20px; 

代码结构


官方文档的方向滑动的回调方法由于我人品问题根本没有起作用,然后自己跟根据起始停止点位计算方法算出方向。

  1. touchStart(e){ 
  2.     back.touchPointX = e.touches[0].localX 
  3.     back.touchPointY = e.touches[0].localY 
  4. }, 
  5. touchEnd(e){ 
  6.     let endxpoint = e.changedTouches[0].localX 
  7.     let endypoint = e.changedTouches[0].localY 
  8.     back.leavePointX = endxpoint - back.touchPointX 
  9.     back.leavePointY = endypoint - back.touchPointY 
  10.     if (Math.abs(back.leavePointX) > 10 || Math.abs(back.leavePointY) > 10) { 
  11.         if(move.CanMove()){ 
  12.             let fx = move.moveFx(back.leavePointX, back.leavePointY) 
  13.             let movereslut= move.Move(fx); 
  14.             if (movereslut) { 
  15.                 this.createItem() 
  16.                 this.addNumBlank(1); 
  17.             } 
  18.         }else
  19.             this.reNumBlank(); 
  20.             this.createItem(); 
  21.             this.addNumBlank(2); 
  22.         } 
  23.     } 

 移动后效果


上架

目前文档中需要被邀请的开发者才能打包调试,所以给官方发完邮件后也得到了开发者的开通。


官方打包调试上架文档:

https://developer.huawei.com/consumer/cn/doc/distribution/app/agc-harmonyapp-releaseharmonyapp#h1-1598338018957

根据文档获取Profile文件,在IED>File>Project Structure>Project中配置相关信息就可以Build出app包文件


按文档页面填写信息即可提交你的app

接下来就是等待审核了


篇外

看到有奖品第一次写这种分享文章,希望不要喷的太重。另外一个自己写着玩的音乐播放器还在停停写写很久了,希望中奖有动力把这个完成下来。


想了解更多内容,请访问:

51CTO和华为官方合作共建的鸿蒙技术社区

https://harmonyos.51cto.com/#zz

 

责任编辑:jianghua 来源: 鸿蒙社区
相关推荐

2020-12-14 09:58:28

鸿蒙HarmonyOS手表游戏

2020-12-11 12:27:35

鸿蒙HarmonyOS

2022-07-11 16:26:37

eTS计算鸿蒙

2020-12-23 09:58:37

HarmonyOSHAPAPP

2020-12-11 12:45:04

鸿蒙Hi3861游戏

2020-12-22 11:20:36

鸿蒙HarmonyOS游戏

2023-03-14 21:19:29

云函数云数据库

2023-03-15 16:24:43

云数据库代码开发

2022-11-01 15:17:48

JS鸿蒙小游戏

2023-08-07 15:18:29

游戏开发鸿蒙Arkts

2020-12-14 11:44:29

开发js智能手表wearablewea

2020-12-28 10:15:18

鸿蒙HarmonyOSListContain

2022-07-29 14:47:34

数独Sudoku鸿蒙

2022-10-19 15:19:53

数独Sudoku鸿蒙

2022-10-18 15:45:17

数独Sudoku鸿蒙

2022-10-19 15:27:36

数独Sudoku鸿蒙

2022-08-25 21:41:43

ArkUI鸿蒙

2020-12-28 11:19:06

鸿蒙HarmonyOSPage Abilit

2022-10-31 15:22:37

JS鸿蒙小游戏

2015-08-27 14:04:41

运维IT
点赞
收藏

51CTO技术栈公众号