windlany / Wechat Weapp 2048
微信小程序-2048小游戏
Stars: ✭ 406
Programming Languages
javascript
184084 projects - #8 most used programming language
Labels
Projects that are alternatives of or similar to Wechat Weapp 2048
Wechat App Music
微信小程序:音乐播放器 技术栈: redux + es7 +labrador
Stars: ✭ 384 (-5.42%)
Mutual labels: wechat-app, wechat
Supermarketmini
基于wepy2.x 仿苏宁小店小程序,API采用go开发(已开源),项目正在开发中,欢迎加群:160301726
Stars: ✭ 73 (-82.02%)
Mutual labels: wechat-app, wechat
Tom Vpr
how does voiceprint recognition work in wechat page
Stars: ✭ 37 (-90.89%)
Mutual labels: wechat-app, wechat
Mpvue Animated Number
微信小程序 mpvue 数字更新滚动动画组件 / An animated number component for mpvue
Stars: ✭ 33 (-91.87%)
Mutual labels: wechat-app, wechat
Wechat Miniprogram Ar 3d
A WeChat MiniProgram 3D that includes a Panorama Viewer and a 3D Viewer using the device orientation control.
Stars: ✭ 80 (-80.3%)
Mutual labels: wechat-app, wechat
Python Weixin
微信(weixin|wechat) Python SDK 支持开放平台和公众平台 支持微信小程序云开发
Stars: ✭ 746 (+83.74%)
Mutual labels: wechat-app, wechat
Weixin Java Miniapp Demo
基于Spring Boot 和 WxJava 实现的微信小程序Java后端Demo
Stars: ✭ 779 (+91.87%)
Mutual labels: wechat-app, wechat
Wechat Weapp Grouputils
微信小程序群应用,包括群通知、群接龙、群投票、群通讯录4大功能
Stars: ✭ 222 (-45.32%)
Mutual labels: wechat-app, wechat
Wepy Mall
微信小程序--基于wepy 商城(微店)微信小程序 欢迎学习交流
Stars: ✭ 3,224 (+694.09%)
Mutual labels: wechat-app, wechat
2048
效果图
算法
该程序主要难度在用户滑动屏幕时值相同的cell合并 将空格标为0(我代码中是用的""表示空格),假设棋盘如下:
- 0 2 0 2
- 0 0 0 0
- 0 0 0 2
- 0 0 0 0
步骤
- 通过touch相关的事件函数确定用户滑动方向
- 将棋盘的数字生成4*4的二维数组list
- 根据用户滑动方向生成四个小数组,比如用户将上面的棋盘向右滑动,则四个数组为:
item[0] = [2, 0, 2, 0]; item[1] = [0, 0, 0, 0]; item[2] = [2, 0, 0, 0]; // 注意是2000而不是0002,因为是向右滑动要从右边开始 item[3] = [0, 0, 0, 0];
- 接下来就是滑动时合并,拿item[0]举例,如果是2020,向右滑动我们应该成为0004
- 将item[0]的所有0移到末尾变为2200,遍历item将相同的下标值相加,后面的数置为0
- 2020 ---> 2200 ---> 4200 ----> 4000
- 如法炮制就可以实现滑动时合并
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].