search
HomeWeChat AppletMini Program DevelopmentImplementation of WeChat mini program version of card flipping mini game

This article mainly introduces the WeChat Mini Program version of the card flipping mini game in detail. It has certain reference value. Interested friends can refer to it.

The example in this article is to share with you the WeChat Mini Program. The specific code of the program flop game is for your reference. The specific content is as follows

1. Create a new quick start project to see the structure

Develop tools in WeChat Click Add Project, select no appid, and check "Create a quick start project in the current directory".

You can see that there are two directories, pages and utils, and 3 app files in the root directory. Pages stores the pages of the mini program, and each page has its own independent folder. A page consists of 4 files. The js file is the program logic; wxss is a style file defined by WeChat. The syntax is the same as css, but it supports fewer styles; the wxml file is used to define the interface of the mini program, and its function is similar to html, but only Some tags customized by WeChat can be used, and page elements cannot be directly operated with js and can only be modified by binding data; json is the configuration file of the page and is generally not used. The functions of app.js, app.json, and app.wxml in the root directory are similar to those under pages, except that those under pages are at the page level, while those under the root directory are at the application level>. A tool function for converting time format is defined below in utils, and then the function is exposed through module.exports, and then introduced through require in logs.js.

2. Transform the index page

Once you know the structure of the mini program, you can start. First, transform the index page and add the user avatar. Remove the click event, and then add two buttons to jump to the main game interface and game results interface.

1. Interface, bindtap is equivalent to onclick of html

<!--index.wxml--> 
<view class="container"> 
 <view class="userinfo"> 
 <text class="userinfo-nickname"></text> 
 <image class="userinfo-avatar" src="{{userInfo.avatarUrl}}" background-size="cover"></image> 
 <text class="userinfo-nickname">{{userInfo.nickName}}</text> 
 <text class="userinfo-nickname">你好</text> 
 </view> 
 <view class="usermotto" > 
 <text class="user-motto" bindtap="startGame">{{motto}}</text> 
 </view> 
 <view style="margin-top:30rpx; "> 
 <text class="user-motto" bindtap="viewScore" >查看排名</text> 
 </view> 
</view>

2.In Page of index.js file Add two functions to handle click events, use wx.navigateTo to jump to the target page

//index.js 
//获取应用实例 
var app = getApp() 
Page({ 
 data: { 
 motto: &#39;开始游戏&#39;, 
 userInfo: {}, 
 welcome:&#39;你好&#39; 
 }, 
 //事件处理函数 
 startGame: function() { 
 wx.navigateTo({ 
  url: &#39;../game/game&#39; 
 }) 
 },viewScore: function() { 
 wx.navigateTo({ 
  url: &#39;../logs/logs&#39; 
 }) 
 }, 
 onLoad: function () { 
 console.log(&#39;onLoad&#39;) 
 var that = this 
 //调用应用实例的方法获取全局数据 
 app.getUserInfo(function(userInfo){ 
  //更新数据 
  that.setData({ 
  userInfo:userInfo 
  }) 
 }) 
 } 
})

3.Add game background to index.wxss Picture

page{background: url(&#39;../images/gamebg.jpg&#39;) center top; }

The above is the entire content of this article. I hope it will be helpful to everyone’s study. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

WeChat applet implements the function of selecting cities based on letters

WeChat applet imitates Meituan City Selected implementation

Snake game implemented by WeChat applet [with source code]

##

The above is the detailed content of Implementation of WeChat mini program version of card flipping mini game. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.