game-shake
v0.0.1
Published
``` npm install game-shake ```
Downloads
8
Readme
game-shake
游戏
安装
npm install game-shake
使用
必须开启 "enableSkia": "true"
- json
{
"usingComponents": {
"game": "game-shake/index"
}
}
- mini.project.json
{
"node_modules_es6_whitelist": [
"common-game"
]
}
- js
Page({
data: {
gameSource: JSON.stringify({
baseOps: {
speed: { min: 10, max: 30, step: 1, intervalstepH: 1000 },//移动速度
firstY: 200,//首次加载游戏第一个元素的底部坐标位置
intervalStep: 1,//两个物体之间的间隔递减值
intervalStepH: 50,//移动指定距离递减一次
minIntervalH: 50,//两个物体之间的最小间隔距离
maxIntervalH: 100,//两个物体之间的间隔距离
maxCols: 5,//一共有多少列
offsetX: 100,//前后随机距离
maxAngule: 30,//杯子旋转角度
angSpeed: 3,//旋转速度
angBeishu: 1,//旋转倍数
startAngule: 30,//星星出现的角度
renderNum: { min: 3, max: 5 },//一次随机生成多少个元素
},
items: [
{ src: "https://img.alicdn.com/imgextra/i2/2185320355/O1CN01QaQ77a1EUdOexRH27_!!2185320355.png", probability: 1, },
{ src: "https://img.alicdn.com/imgextra/i1/2185320355/O1CN01uSmfjq1EUdOexR8il_!!2185320355.png", probability: 1, },
{ src: "https://img.alicdn.com/imgextra/i2/2185320355/O1CN01E06KHN1EUdORZwLXA_!!2185320355.png", probability: 1, },
{ src: "https://img.alicdn.com/imgextra/i2/2185320355/O1CN01UyLtZ41EUdObOtnb1_!!2185320355.png", probability: 1, },
{ src: "https://img.alicdn.com/imgextra/i4/2185320355/O1CN01jhwHs81EUdOaeaBXf_!!2185320355.png", probability: 1, },
],
player: {
curIdx: 0,//当前玩家下标
arr: [
{ src: "https://img.alicdn.com/imgextra/i1/2185320355/O1CN01SBcB5s1EUdOjZF4gQ_!!2185320355.png", bound: { left: 0, right: 0, bottom: 0, top: 0 }, moveY: false, top: 100, },
{ src: "https://img.alicdn.com/imgextra/i2/2185320355/O1CN01JmMYRZ1EUdOUNVeih_!!2185320355.png", bound: { left: 0, right: 0, bottom: 0, top: 0 }, moveY: false, top: 100, },
{ src: "https://img.alicdn.com/imgextra/i3/2185320355/O1CN01YULK2g1EUdOUNWG9l_!!2185320355.png", bound: { left: 0, right: 0, bottom: 0, top: 0 }, moveY: false, top: 100, },
]
},
}),
},
onLoad(query) {
},
playFun() {
// this.gameComponent.onEvent("play");//打开音效
// this.gameComponent.onEvent("mute");//关闭音效
this.gameComponent.onEvent("start");
},
stopFun() {
this.gameComponent.onEvent("stop");
},
resetFun() {
this.gameComponent.onEvent("reset");
},
onInitDone(e) {
this.gameComponent = e.ref;
console.log("游戏初始化完成", e)
},
})
- xaml
<view class="pageBox">
<game gameSource="{{gameSource}}" onInitDone="onInitDone" />
</view>
<view onTap="playFun" style="position:absolute;left: 30%;bottom: 100rpx;">开始</view>
<view onTap="stopFun" style="position:absolute;left: 40%;bottom: 100rpx;">结束</view>
<view onTap="resetFun" style="position:absolute;left: 50%;bottom: 100rpx;">重置</view>
-acss
.pageBox{
position: absolute;
width: 750rpx;
height: 1700rpx;
left: 50%;
top: 50%;
transform: translateX(-50%) translateY(-50%);
background-color: #ccc;
}