消消乐python代码_闲来无事写了个“消消乐”鸿蒙小游戏!
发布日期:2021-06-24 14:01:27 浏览次数:2 分类:技术文章

本文共 2185 字,大约阅读时间需要 7 分钟。

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

在官方文档中看到有 HarmonyOS 上架相关的文档,并体验了下上架流程。

PS:11 月 18 号提交的上架现在都没有审核反馈,如果不让上其实官方可以打回的。

代码一直放着今天看到有征文有奖所以才想到发上来,征文地址:
https://harmonyos.51cto.com/posts/1940#shequbanner

01

基本布局

78a9be1af1d633979087c7f9138f8b85.png 页面还是用宫格布局,上方文字显示当前动物,宫格显示动物图片。
 
"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

代码结构

afd1545ab5b0eba917c442545beedc04.png 官方文档的方向滑动的回调方法由于我人品问题根本没有起作用,然后自己跟根据起始停止点位计算方法算出方向。
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

移动后效果

f4d03f3468ee2dc468b13cd9061c25e3.png

04

上架

目前文档中需要被邀请的开发者才能打包调试,所以给官方发完邮件后也得到了开发者的开通。
c3920748b8142ffa49d4da32eea2d4ab.png 官方打包调试上架文档:
https://developer.huawei.com/consumer/cn/doc/distribution/app/agc-harmonyapp-releaseharmonyapp#h1-1598338018957
根据文档获取 Profile 文件,在 IED→File→Project Structure→Project 中配置相关信息就可以 Build 出 app 包文件。
402b0a9c1fe38c8fe386894f954b932b.png 按文档页面填写信息即可提交你的 app
217d0da71b24c9d581c3e7078a7db3ef.png 接下来就是等待审核了!

6ba5e97d3ca10fd384950851c98473f7.png

05

篇外

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

699d30b491f45ab7d582665c0d59a349.png

25caa343a2f94820b14c05ce96afaf51.gif

点“阅读原文”下载源码

转载地址:https://blog.csdn.net/weixin_33305027/article/details/112331819 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:sol存档文件打不开_FLASH游戏存档相关
下一篇:ios 点击出现另外一套tabbar_iOS版微信7.0.20重磅更新:发现页新增附近的直播和人...

发表评论

最新留言

第一次来,支持一个
[***.219.124.196]2024年04月09日 09时13分08秒