This commit is contained in:
TxZgX
2021-12-23 15:44:54 +08:00
parent 204ea47edf
commit e0703136c1
18 changed files with 195 additions and 24 deletions

View File

@@ -13,9 +13,9 @@ ohos {
certpath file('C:\\Users\\honor\\.ohos\\config\\auto_debug_myapplication_56657123.cer')
}
}
compileSdkVersion 5
compileSdkVersion 7
defaultConfig {
compatibleSdkVersion 4
compatibleSdkVersion 6
}
buildTypes {
release {

View File

@@ -1,10 +1,13 @@
{
"app": {
"apiVersion": {
"compatible": 3
},
"bundleName": "com.xcl20481.myapplication",
"vendor": "xcl20481",
"version": {
"code": 1000000,
"name": "1.0.1"
"name": "1.0.2"
}
},
"deviceConfig": {
@@ -16,6 +19,11 @@
"package": "com.xcl20481.myapplication",
"name": ".MyApplication",
"mainAbility": "com.xcl20481.myapplication.MainAbility",
"reqPermissions": [
{
"name": "ohos.permission.VIBRATE"
}
],
"deviceType": [
"phone",
"tablet",
@@ -52,6 +60,7 @@
"js": [
{
"pages": [
"pages/page0/page0",
"pages/index/index"
],
"name": "default",

View File

@@ -1,8 +1,6 @@
package com.xcl20481.myapplication;
import ohos.ace.ability.AceAbility;
import ohos.aafwk.content.Intent;
public class MainAbility extends AceAbility {
@Override
public void onStart(Intent intent) {

View File

@@ -1,8 +1,7 @@
export default {
onCreate() {
console.info('AceApplication onCreate');
},
onDestroy() {
console.info('AceApplication onDestroy');
}
};

View File

@@ -10,17 +10,19 @@
width: 70px;
height: 17px;
letter-spacing: 0px;
font-size: 11px;
margin-top: 1.8px;
font-size: 11.5px;
margin-top: 1px;
margin-bottom:3px;
color: #eb0bc7f6;
}
.best{
text-align: center;
width: 60px;
height: 17px;
font-size: 12px;
font-size: 12.5px;
letter-spacing: 0px;
margin-top: 8.5px;
margin-top: 8.3px;
color: #64f6f3;
}
.tile-wrap{
width: 150px;
@@ -57,9 +59,9 @@
height: 150px;
justify-content: center;
align-items: center;
background-color: transparent;
background-color: black;
}
.gameover{
font-size: 20px;
font-size: 30px;
color: #FF7500;
}

View File

@@ -1,4 +1,5 @@
import brightness from '@system.brightness';
import vibrator from '@system.vibrator';
let numbers,newNumbers;
export default{
data:{
@@ -108,7 +109,22 @@ export default{
numbers=newNumbers;
},
isGameOver(){
if(this.isGridsFull()==true && this.isGridsNotMergeable()==true) return true;
if(this.isGridsFull()==true && this.isGridsNotMergeable()==true){
vibrator.vibrate({
mode: 'long',
success: function(ret) {
console.log('vibrate is successful');
},
fail: function(ret) {
console.log('vibrate is failed');
},
complete: function(ret) {
console.log('vibrate is completed');
}
});
console.info('游戏结束');
return true;
}
},
isGridsFull(){
if(numbers.indexOf(0)==-1){return true;}

View File

@@ -0,0 +1,42 @@
.container{
width: 227px;
height: 227px;
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
text-align: center;
width: 140px;
height: 62px;
letter-spacing: 0px;
font-size: 19px;
margin-top: 40px;
margin-bottom:3px;
color: #eb0750cb;
}
.title1 {
text-align: center;
width: 180px;
height: 150px;
font-size: 15.5px;
margin-top: 5px;
margin-bottom:5px;
color: #eb0597bb;
}
.btn{
width: 65.5px;
height: 35.5px;
background-color: #155ddc;
margin-top: 5px;
font-size: 13px;
margin-bottom: 3px;
}
.btn1{
width: 65.5px;
height: 35.5px;
background-color: #155ddc;
margin-top: 5px;
font-size: 13px;
margin-bottom: 5px;
}

View File

@@ -0,0 +1,10 @@
<div class="container">
<text class="title">
《2048小游戏》
</text>
<text class="title1">
开始游戏即默认同意我的隐私声明:www.xuegao-tzx.top/g2048h.html
</text>
<input class="btn" type="button" value="开始" onclick="ToStart"></input>
<input class="btn1" type="button" value="退出" onclick="ToClose"></input>
</div>

View File

@@ -0,0 +1,70 @@
import router from '@system.router'
import app from '@system.app'
import brightness from '@system.brightness';
import vibrator from '@system.vibrator';
import prompt from '@system.prompt';
export default {
onInit() {
brightness.setKeepScreenOn({keepScreenOn: true,});
brightness.setMode({mode: 1,});
},
onSwipe(e) {
switch (e.direction) {
case 'left':
break;
case 'right':
break;
case 'up':
break;
case 'down':
break;
}
},
onlongpress(){
console.log('tzx 11');
prompt.showToast({
message: 'Message Info',
duration: 2000,
});
},
ToStart(){
vibrator.vibrate({
mode: 'short',
success: function(ret) {
console.log('tzx vibrate is successful');
},
fail: function(ret) {
console.log('tzx vibrate is failed');
},
complete: function(ret) {
console.log('tzx vibrate is completed');
}
});
prompt.showToast({
message: '开始成功By Xcl!',
duration: 3000,
});
router.replace({
uri: "pages/index/index",
});
},
ToClose(){
prompt.showToast({
message: '退出成功!',
duration: 3500,
});
vibrator.vibrate({
mode: 'short',
success: function(ret) {
console.log('tzx vibrate is successful');
},
fail: function(ret) {
console.log('tzx vibrate is failed');
},
complete: function(ret) {
console.log('tzx vibrate is completed');
}
});
app.terminate();
},
}