本文共 2185 字,大约阅读时间需要 7 分钟。
那天在论坛里看到张荣超老师发了一个 2048 的游戏,后面就想到自己用 2048 的玩法写个十二生肖主题的消消乐的游戏写着玩玩。
在官方文档中看到有 HarmonyOS 上架相关的文档,并体验了下上架流程。
PS:11 月 18 号提交的上架现在都没有审核反馈,如果不让上其实官方可以打回的。
代码一直放着今天看到有征文有奖所以才想到发上来,征文地址:https://harmonyos.51cto.com/posts/1940#shequbanner
01
基本布局
页面还是用宫格布局,上方文字显示当前动物,宫格显示动物图片。"touchStart" ontouchend="touchEnd" class="container">
class="zoon"> { {zoon}}
class="wins" ref="wins">"cantx" ref="canvas" class="cantx" focusable="true" >"button" value="重新开始" class="btn" onclick="reset"/>
/* index.css */.container { flex-direction: column; width: 90%; height: 90%; background-color: black;}.wins{ width: 290px; height: 290px; margin-left: 80px; margin-top: 80px;}.cantx{ width: 290px; height: 290px;}.btn { width: 175px; height: 50px; background-color: #AD9D8F; font-size: 24px; margin-top: 10px; margin-left: 140px;}.zoon { position: absolute; margin-left: 200px; font-size: 18px; text-align: center; width: 100px; height: 50px; margin-top: 20px;}
02
代码结构
官方文档的方向滑动的回调方法由于我人品问题根本没有起作用,然后自己跟根据起始停止点位计算方法算出方向。touchStart(e){ back.touchPointX = e.touches[0].localX back.touchPointY = e.touches[0].localY }, touchEnd(e){ let endxpoint = e.changedTouches[0].localX let endypoint = e.changedTouches[0].localY back.leavePointX = endxpoint - back.touchPointX back.leavePointY = endypoint - back.touchPointY if (Math.abs(back.leavePointX) > 10 || Math.abs(back.leavePointY) > 10) { if(move.CanMove()){ let fx = move.moveFx(back.leavePointX, back.leavePointY) let movereslut= move.Move(fx); if (movereslut) { this.createItem() this.addNumBlank(1); } }else{ this.reNumBlank(); this.createItem(); this.addNumBlank(2); } } }
03
移动后效果
04
上架
目前文档中需要被邀请的开发者才能打包调试,所以给官方发完邮件后也得到了开发者的开通。 官方打包调试上架文档:https://developer.huawei.com/consumer/cn/doc/distribution/app/agc-harmonyapp-releaseharmonyapp#h1-1598338018957根据文档获取 Profile 文件,在 IED→File→Project Structure→Project 中配置相关信息就可以 Build 出 app 包文件。 按文档页面填写信息即可提交你的 app 接下来就是等待审核了!
05
篇外
看到有奖品第一次写这种分享文章,希望不要喷的太重。另外一个自己写着玩的音乐播放器还在停停写写很久了,希望中奖有动力把这个完成下来。点“阅读原文”下载源码
转载地址:http://kztdy.baihongyu.com/