0.0.18 • Published 2 years ago
game-tiger v0.0.18
game-tiger
游戏
安装
npm install game-tiger
使用
必须开启 "enableSkia": "true"
- json
{
"usingComponents": {
"game": "game-tiger/index"
}
}
- mini.project.json
{
"node_modules_es6_whitelist": [
]
}
- js
Page({
data: {
showBool: true,
gameSource: {
"publicProper": {
"moveTime": 36, // 速度基数 2的整数倍
"speedArry": [4, 6, 8, 10], // 加数
"specialSpeed": 14, // 飞行模式速度 固定
"time": 60, // 秒数
"life": 3, // 生命值
"special": 5000, // 变身限制分数
"mousLeng": 10, // 触摸灵敏度
"check": 1, // 碰撞检测 0 头1 尾巴
"addscore1": 5000, // 第一次加时分数
"addscore2": 10000, // 第二次加时分数
"addTime1": 15, // 第一次加时
"addTime2": 30, // 第二次加时
"fudaiIndex": 4, // 福袋配置下标
"addSpend": 20, // 每20s加一次速度
"bgh": 8, // 背景移动速度
"g_TICK": 16, // update刷新
"g_count": 60 // update刷新频率
},//
"imag": {
// "bg3Imag": { "img": "resources/bg", "count": 11, "x": 375, "y": 850 },
"bgImag": { "img": "https://img.alicdn.com/imgextra/i3/1080040467/O1CN01UkI8nz1FJvguABMfX_!!1080040467.png", "width": 375, "height": 850 },
"lbImag": { "img": "https://img.alicdn.com/imgextra/i4/1080040467/O1CN01453IF81FJvh3269b4_!!1080040467.png", "width": 172, "height": 220, "width2": 580 },
"fdgbImag": { "img": "https://img.alicdn.com/imgextra/i2/1080040467/O1CN015X47M31FJvgnX6ly0_!!1080040467.png", "width": 165, "height": 220 },
"tigerImag": { "img": "https://img.alicdn.com/imgextra/i4/1080040467/O1CN013X5D9M1FJvglKGj9K_!!1080040467.png", "x": 580, "y": 250, "width": 36, "height": 24, "scale": 1.2 },
"pointsImag": { "img": "https://img.alicdn.com/imgextra/i3/1080040467/O1CN01wO7WAs1FJvgoqys5r_!!1080040467.png", "x": 172, "y": 250, "width": 83, "height": 17, "scale": 1.2 },
"bgAnimImage": {
"x": 375, "y": 850,
"src":
[
{ "url": "https://img.alicdn.com/imgextra/i2/555657275/O1CN011dawga23c06qEt50Y_!!555657275.jpg", "name": "0.jpg", "width": "750", "height": "850" },
{ "url": "https://img.alicdn.com/imgextra/i4/555657275/O1CN01knGdGD23c06oMaMnu_!!555657275.jpg", "name": "2.jpg", "width": "750", "height": "850" },
{ "url": "https://img.alicdn.com/imgextra/i4/555657275/O1CN01OfewBG23c06pWc17L_!!555657275.jpg", "name": "4.jpg", "width": "750", "height": "850" },
{ "url": "https://img.alicdn.com/imgextra/i3/555657275/O1CN01uKE5gV23c06jY2WTt_!!555657275.jpg", "name": "6.jpg", "width": "750", "height": "850" },
{ "url": "https://img.alicdn.com/imgextra/i2/555657275/O1CN01ygwC1v23c06hKz7Ml_!!555657275.jpg", "name": "8.jpg", "width": "750", "height": "850" },
{ "url": "https://img.alicdn.com/imgextra/i2/555657275/O1CN0166FPcq23c06kA3Tss_!!555657275.jpg", "name": "10.jpg", "width": "750", "height": "850" },
{ "url": "https://img.alicdn.com/imgextra/i4/555657275/O1CN01DRaVzJ23c06oMZ9xN_!!555657275.jpg", "name": "12.jpg", "width": "750", "height": "850" },
{ "url": "https://img.alicdn.com/imgextra/i3/555657275/O1CN01Fzkutc23c06f6iFkG_!!555657275.jpg", "name": "14.jpg", "width": "750", "height": "850" },
{ "url": "https://img.alicdn.com/imgextra/i2/555657275/O1CN01tdaK9Q23c06lWj3si_!!555657275.jpg", "name": "16.jpg", "width": "750", "height": "850" },
{ "url": "https://img.alicdn.com/imgextra/i1/555657275/O1CN01jLSLAb23c06lWjCCE_!!555657275.jpg", "name": "18.jpg", "width": "750", "height": "850" },
{ "url": "https://img.alicdn.com/imgextra/i3/555657275/O1CN01lmTSvl23c06s33CNy_!!555657275.jpg", "name": "20.jpg", "width": "750", "height": "850" },
{ "url": "https://img.alicdn.com/imgextra/i1/555657275/O1CN01VHyjDM23c06kA1wG4_!!555657275.jpg", "name": "22.jpg", "width": "750", "height": "850" },
{ "url": "https://img.alicdn.com/imgextra/i1/555657275/O1CN01PlHo0I23c06lWinFL_!!555657275.jpg", "name": "24.jpg", "width": "750", "height": "850" },
{ "url": "https://img.alicdn.com/imgextra/i4/555657275/O1CN01BwYGGl23c06rM6yx6_!!555657275.jpg", "name": "26.jpg", "width": "750", "height": "850" },
{ "url": "https://img.alicdn.com/imgextra/i3/555657275/O1CN01FugEIl23c06aIBMwt_!!555657275.jpg", "name": "28.jpg", "width": "750", "height": "850" },
{ "url": "https://img.alicdn.com/imgextra/i1/555657275/O1CN01luJNc723c06f6heLS_!!555657275.jpg", "name": "30.jpg", "width": "750", "height": "850" },
{ "url": "https://img.alicdn.com/imgextra/i4/555657275/O1CN01fZWRoA23c06lWiK9W_!!555657275.jpg", "name": "32.jpg", "width": "750", "height": "850" },
{ "url": "https://img.alicdn.com/imgextra/i3/555657275/O1CN01XsOGGZ23c06gf3Glb_!!555657275.jpg", "name": "34.jpg", "width": "750", "height": "850" },
{ "url": "https://img.alicdn.com/imgextra/i3/555657275/O1CN01VObfMb23c06ni2mqI_!!555657275.jpg", "name": "36.jpg", "width": "750", "height": "850" },
{ "url": "https://img.alicdn.com/imgextra/i2/555657275/O1CN01CXrAQy23c06kA14DL_!!555657275.jpg", "name": "38.jpg", "width": "750", "height": "850" },
]
},
},
"label": {
"scoreLb": {
"fontSize": 33, "fill": 0xFFFFFF, "width": 172, "height": 206, "anchorX": 0, "anchorY": 0.5, "width2": 580, "path":
[{ "src": "https://img.alicdn.com/imgextra/i4/1080040467/O1CN01fKj2ia1FJvgkeN5se_!!1080040467.png", "name": "font_0.png", "width": 33, "height": 33 },
{ "src": "https://img.alicdn.com/imgextra/i3/1080040467/O1CN017FudCe1FJvgkeOq0h_!!1080040467.png", "name": "font_1.png", "width": 13, "height": 33 },
{ "src": "https://img.alicdn.com/imgextra/i2/1080040467/O1CN01wMeVNu1FJvgvwZvOm_!!1080040467.png", "name": "font_2.png", "width": 23, "height": 33 },
{ "src": "https://img.alicdn.com/imgextra/i4/1080040467/O1CN01ZqxB8E1FJvgvwdc6K_!!1080040467.png", "name": "font_3.png", "width": 23, "height": 33 },
{ "src": "https://img.alicdn.com/imgextra/i2/1080040467/O1CN01wY5GBD1FJvgvwd8zC_!!1080040467.png", "name": "font_4.png", "width": 27, "height": 33 },
{ "src": "https://img.alicdn.com/imgextra/i2/1080040467/O1CN01vqmQCP1FJvgo84Cx7_!!1080040467.png", "name": "font_5.png", "width": 24, "height": 33 },
{ "src": "https://img.alicdn.com/imgextra/i1/1080040467/O1CN01L2DvzI1FJvgnQcEV4_!!1080040467.png", "name": "font_6.png", "width": 24, "height": 33 },
{ "src": "https://img.alicdn.com/imgextra/i2/1080040467/O1CN01fgfCX71FJvgrfqUK2_!!1080040467.png", "name": "font_7.png", "width": 23, "height": 33 },
{ "src": "https://img.alicdn.com/imgextra/i4/1080040467/O1CN0190EBPA1FJvgkeMpG4_!!1080040467.png", "name": "font_8.png", "width": 25, "height": 33 },
{ "src": "https://img.alicdn.com/imgextra/i3/1080040467/O1CN01Oh536m1FJvglKHw0U_!!1080040467.png", "name": "font_9.png", "width": 28, "height": 33 },
{ "src": "https://img.alicdn.com/imgextra/i3/1080040467/O1CN01DH3OU21FJvgpSWhWM_!!1080040467.png", "name": "font_s.png", "width": 9, "height": 26 },
]
}
},
"player": {
"idleImage": { "img": "https://img.alicdn.com/imgextra/i4/1080040467/O1CN013jHMyX1FJvgo8FtJZ_!!1080040467.png", "width": 1905, "height": 2000, "xwidth": 190.5, "yheight": 333, "xNum": 10, "yNum": 6 },
"flyImage": { "img": "https://img.alicdn.com/imgextra/i1/1080040467/O1CN01nY6Bq11FJvglKULzm_!!1080040467.png", "width": 2000, "height": 1221, "xwidth": 400, "yheight": 244.2, "xNum": 5, "yNum": 5 },
"jumpImage": { "img": "https://img.alicdn.com/imgextra/i4/1080040467/O1CN01OvFIP81FJvgnQoaPJ_!!1080040467.png", "width": 572, "height": 2010, "xwidth": 114.4, "yheight": 402, "xNum": 5, "yNum": 5 },
"runImage": { "img": "https://img.alicdn.com/imgextra/i3/1080040467/O1CN01Te4Gss1FJvgnXHzC1_!!1080040467.png", "width": 704, "height": 1900, "xwidth": 176, "yheight": 475, "xNum": 4, "yNum": 4 },
"setFlyImage": { "img": "https://img.alicdn.com/imgextra/i4/1080040467/O1CN01bs6yng1FJvgo8F9ae_!!1080040467.png", "width": 2004, "height": 1020, "xwidth": 334, "yheight": 255, "xNum": 6, "yNum": 4 },
"jumpHeight": 20, // 老虎移动速度
"posX": 375, // 老虎坐标
"posY": 980, // 老虎坐标
"setpIndex": 2, // 碰撞检测位置
"width": 200, // 老虎宽度
"height": 320, // 老虎宽度
"animationSpeed": 2, // 老虎动画播放倍率 idel
"animationRunSpeed": 2, // 老虎动画播放倍率
"animationJumPSpeed": 2, // 老虎动画播放倍率
"animationSetSpeed": 2, // 老虎动画播放倍率
"animationFiySpeed": 2, // 老虎动画播放倍率
"scale": 0.5, // 老虎尺寸缩放
"scaleIdle": 0.8, // 老虎尺寸缩放
"scaleRun": 0.65, // 老虎尺寸缩放
"scaleJump": 1.1, // 老虎尺寸缩放
"scaleSet": 1.8, // 老虎尺寸缩放
"scaleFly": 1.5, // 老虎尺寸缩放
"jump": 350, // 跳动高度
"widhtX": 20, // 老虎白色透明区域
"heightY": 30, // 老虎白色透明区域
"twinkNum": 2, // 闪烁次数
"twinkSpeed": 2, // 闪烁次数速度
"setY": 325,
"setPosX": [187.5, 375, 562.5], // 变身高度(因动画尺寸原因被放大n倍)
"setPosX1": [187.5, 375, 562.5], // 变身高度(因动画尺寸原因被放大n倍)
},
"steps": {
"proper": { "img": "https://img.alicdn.com/imgextra/i2/1080040467/O1CN01QQSTDA1FJvgnX4MHp_!!1080040467.png", "width": 728, "height": 450, "x": 0, "y": 300, "y1": 250, "scale": 0.3 },//初始属性
"stepMax": 6, // 物品绘制行数
"stepGap": 250, // 行间隔
"stepPow": 1.5, // 行缩放比例(公比)
"stepRNnum": 3, // 无陷阱数:
"stepFNnum": 3, // 无果实物
"roads": [ // 陷阱配置
{ "x": 0, "y": 0, "width": 80, "height": 40, "img": "https://img.alicdn.com/imgextra/i4/1080040467/O1CN01vpBvVb1FJvgvwdgHG_!!1080040467.png", "probability": 5, "score": 0, "scale1": 0.4, "scale": 1.5, "jump": true },
{ "x": 0, "y": 0, "width": 180, "height": 190, "img": "https://img.alicdn.com/imgextra/i1/1080040467/O1CN01aVNDiz1FJvgo85cHw_!!1080040467.png", "probability": 1, "score": 0, "scale1": 0.15, "scale": 2, "jump": false },
],
"addBuff": [ // 果实配置
{ "x": 0, "y": 0, "width": 115, "height": 115, "img": "https://img.alicdn.com/imgextra/i3/1080040467/O1CN01F5GIYi1FJvgvwcsNM_!!1080040467.png", "probability": 5, "score": 50, "scale1": 0.2, "scale": 1.5 },
{ "x": 0, "y": 0, "width": 85, "height": 85, "img": "https://img.alicdn.com/imgextra/i4/1080040467/O1CN01spWEyi1FJvgnQbYyU_!!1080040467.png", "probability": 5, "score": 50, "scale1": 0.4, "scale": 1.5 },
{ "x": 0, "y": 0, "width": 55, "height": 55, "img": "https://img.alicdn.com/imgextra/i1/1080040467/O1CN01Xr88ic1FJvguABdIO_!!1080040467.png", "probability": 5, "score": 50, "scale1": 0.7, "scale": 1.3 },
{ "x": 0, "y": 0, "width": 45, "height": 45, "img": "https://img.alicdn.com/imgextra/i3/1080040467/O1CN01YL1vEY1FJvglKFNy9_!!1080040467.png", "probability": 5, "score": 50, "scale1": 0.7, "scale": 1.5 },
{ "x": 0, "y": 0, "width": 180, "height": 140, "img": "https://img.alicdn.com/imgextra/i2/1080040467/O1CN01peKEWr1FJvgxXlRsi_!!1080040467.png", "probability": 10, "score": 200, "scale1": 0.2, "scale": 1.5 },
{ "x": 0, "y": 0, "width": 180, "height": 190, "img": "https://img.alicdn.com/imgextra/i2/1080040467/O1CN01yuOr6F1FJvgrfqxQM_!!1080040467.png", "probability": 0, "score": 500, "scale1": 0.2, "scale": 1.5 },
],
"path": [ // 正常模式路径
{ "x1": 0, "x2": 0, "y1": 300, "y2": 1200, "probability": 1 },
{ "x1": -47, "x2": -238, "y1": 300, "y2": 1200, "probability": 1 },
{ "x1": 35, "x2": 238, "y1": 300, "y2": 1200, "probability": 1 }
],
"path2": [ // 特殊模式路径
{ "x1": 0, "x2": 0, "y1": 250, "y2": 1200, "probability": 1 },
{ "x1": 0, "x2": -500, "y1": 250, "y2": 1200, "probability": 1 },
{ "x1": 0, "x2": 500, "y1": 250, "y2": 1200, "probability": 1 }
]
},
}
},
onRef(ref) {
this.ref = ref
console.log("onRef.1..", ref)
},
/**
* @method gameReset
* @for jump_gameControl
* @param {参数类型}
* @return {返回值类型} 无
* desc 加分
*/
onAddScoreNumber(nuemr) {
console.log("onAddScoreNumber__", nuemr)
},
/**
* @method gameReset
* @for jump_gameControl
* @param {参数类型}s=
* @return {返回值类型} 无
* desc 结束
*/
onGameOver(nuemr) {
console.log("onGameOver___score", nuemr)
},
gameShow(ref) {
this.setData({ "showBool": !this.data.showBool })
},
// test
/**
* @method addSpeed
* @for jump_gameControl
* @param {参数类型}
* @return {返回值类型} 无
* desc 加速
*/
addSpeed(ref) {
this.ref.addSpeed();
},
/**
* @method gameBegan
* @for jump_gameControl
* @param {参数类型}
* @return {返回值类型} 无
* desc 开始
*/
gameBegan(ref) {
this.ref.gameBegan();
},
/**
* @method gamePause
* @for jump_gameControl
* @param {参数类型}
* @return {返回值类型} 无
* desc 暂停
*/
gamePause(ref) {
this.ref.gamePause()
},
/**
* @method gameReset
* @for jump_gameControl
* @param {参数类型}
* @return {返回值类型} 无
* desc 重新开始
*/
gameReset(ref) {
this.ref.gameReset()
},
getScoreNum(nuemr) {
console.log("gameScore___", this.ref.getScoreNum())
},
gameSpecial(ref) {
this.ref.gameSpecial()
},
});
- xaml
<view>
<view style="width:100%; height:1200rpx; position:relative;" a:if="{{showBool}}">
<game onRef="onRef" data="{{gameSource}}" onAddScoreNumber="onAddScoreNumber" onGameOver="onGameOver" />
</view>
<view>
<text onTap="gameBegan">开始游戏</text>
<text onTap="gamePause">暂停游戏</text>
<text onTap="gameShow">show game</text>
<text onTap="gameReset">重新开始</text>
<text onTap="addSpeed">速度加一</text>
<text onTap="getScoreNum">玩家分数</text>
<text onTap="gameSpecial">变身</text>
</view>
</view>
-acss