xiulike
v0.0.9
Published
``` npm install xiulike ```
Downloads
2
Readme
修丽可
游戏
安装
npm install xiulike
使用
必须开启 "enableSkia": "true"
- json
{
"usingComponents": {
"game": "xiulike/xiulike"
}
}
- mini.project.json
{
"node_modules_es6_whitelist": [
"common-game"
]
}
- js
Page({
data: {
gameSource: JSON.stringify({
penAudioSrc: "http://isv-vod.alibabausercontent.com/RGjZJMdpNgKGVQeEyw8/qzi1JhFmjUlr04cwc9U?auth_key=1620636097-0-0-6061d706c33f9d4e079fd39c35ddb004&w=0&h=0&e=sd&t=212b054316203768970886677e334d",//喷雾音效
baseOps: {
speed: { min: 5, max: 15, step: 0 },//移动速度
firstY: 200,//首次加载游戏第一个元素的底部坐标位置
intervalStep: 1,//两个物体之间的间隔递减值
intervalStepH: 50,//移动指定距离递减一次
minIntervalH: 300,//两个物体之间的最小间隔距离
maxIntervalH: 500,//两个物体之间的间隔距离
},
energy: [
{ src: "https://img.alicdn.com/imgextra/i1/1080040467/O1CN017gVANl1FJvdfnKqzT_!!1080040467.png", width: 131, height: 124, probability: 1, val: 20, delayTime: 1, replace: { src: "https://img.alicdn.com/imgextra/i4/1080040467/O1CN01X2sbzt1FJvdYLlujC_!!1080040467.png", width: 133, height: 124 } },
{ src: "https://img.alicdn.com/imgextra/i3/1080040467/O1CN014NSqtR1FJvdYLmzGF_!!1080040467.png", width: 117, height: 110, probability: 1, val: 20, delayTime: 1, replace: { src: "https://img.alicdn.com/imgextra/i4/1080040467/O1CN01X2sbzt1FJvdYLlujC_!!1080040467.png", width: 133, height: 124 } },
// { src: "https://img.alicdn.com/imgextra/i4/1080040467/O1CN01X2sbzt1FJvdYLlujC_!!1080040467.png", width: 133, height: 124, probability: 1, val: 20 },
],
scorePos: {
x: 530,
y: 78 / 2,
align: "center",
numOffset: 42,
before: {
src: "https://img.alicdn.com/imgextra/i2/1080040467/O1CN01KuuT3c1FJvdfNMEEG_!!1080040467.png", width: 65, height: 78
},
numArr: [
{ src: "https://img.alicdn.com/imgextra/i2/1080040467/O1CN019wNCJO1FJvdXaZS7V_!!1080040467.png", width: 65, height: 78, val: 0 },
{ src: "https://img.alicdn.com/imgextra/i2/1080040467/O1CN017EiH8T1FJvdhtn4Zs_!!1080040467.png", width: 65, height: 78, val: 1 },
{ src: "https://img.alicdn.com/imgextra/i1/1080040467/O1CN01vrS9HH1FJvdgNTjNY_!!1080040467.png", width: 65, height: 78, val: 2 },
{ src: "https://img.alicdn.com/imgextra/i4/1080040467/O1CN01C45s7P1FJvdesmYC4_!!1080040467.png", width: 65, height: 78, val: 3 },
{ src: "https://img.alicdn.com/imgextra/i3/1080040467/O1CN01eqX6WZ1FJvdZV9PhO_!!1080040467.png", width: 65, height: 78, val: 4 },
{ src: "https://img.alicdn.com/imgextra/i4/1080040467/O1CN01kKNQnJ1FJvdbxmcXr_!!1080040467.png", width: 65, height: 78, val: 5 },
{ src: "https://img.alicdn.com/imgextra/i2/1080040467/O1CN01JuLha21FJvdXaXi0J_!!1080040467.png", width: 65, height: 78, val: 6 },
{ src: "https://img.alicdn.com/imgextra/i1/1080040467/O1CN01hSKboZ1FJvdcxLgan_!!1080040467.png", width: 65, height: 78, val: 7 },
{ src: "https://img.alicdn.com/imgextra/i3/1080040467/O1CN01kak39m1FJvde6A8x8_!!1080040467.png", width: 65, height: 78, val: 8 },
{ src: "https://img.alicdn.com/imgextra/i4/1080040467/O1CN01oTshkz1FJvdgNTGFg_!!1080040467.png", width: 65, height: 78, val: 9 },
]
},
spray: {
x: 236,
y: 78 / 2,
align: "center",
totalNum: 100,//总能量
singleNum: 5,//每次喷雾消耗的能量
numOffset: 42,
tail: {
src: "https://img.alicdn.com/imgextra/i1/1080040467/O1CN01dMeNMI1FJvdfNOJ9O_!!1080040467.png", width: 65, height: 78
},
numArr: [
{ src: "https://img.alicdn.com/imgextra/i2/1080040467/O1CN019wNCJO1FJvdXaZS7V_!!1080040467.png", width: 65, height: 78, val: 0 },
{ src: "https://img.alicdn.com/imgextra/i2/1080040467/O1CN017EiH8T1FJvdhtn4Zs_!!1080040467.png", width: 65, height: 78, val: 1 },
{ src: "https://img.alicdn.com/imgextra/i1/1080040467/O1CN01vrS9HH1FJvdgNTjNY_!!1080040467.png", width: 65, height: 78, val: 2 },
{ src: "https://img.alicdn.com/imgextra/i4/1080040467/O1CN01C45s7P1FJvdesmYC4_!!1080040467.png", width: 65, height: 78, val: 3 },
{ src: "https://img.alicdn.com/imgextra/i3/1080040467/O1CN01eqX6WZ1FJvdZV9PhO_!!1080040467.png", width: 65, height: 78, val: 4 },
{ src: "https://img.alicdn.com/imgextra/i4/1080040467/O1CN01kKNQnJ1FJvdbxmcXr_!!1080040467.png", width: 65, height: 78, val: 5 },
{ src: "https://img.alicdn.com/imgextra/i2/1080040467/O1CN01JuLha21FJvdXaXi0J_!!1080040467.png", width: 65, height: 78, val: 6 },
{ src: "https://img.alicdn.com/imgextra/i1/1080040467/O1CN01hSKboZ1FJvdcxLgan_!!1080040467.png", width: 65, height: 78, val: 7 },
{ src: "https://img.alicdn.com/imgextra/i3/1080040467/O1CN01kak39m1FJvde6A8x8_!!1080040467.png", width: 65, height: 78, val: 8 },
{ src: "https://img.alicdn.com/imgextra/i4/1080040467/O1CN01oTshkz1FJvdgNTGFg_!!1080040467.png", width: 65, height: 78, val: 9 },
],
bg: {
showPos: {
width: 200,
height: 80,
x: 136,
y: 0
},
def: { src: "https://img.alicdn.com/imgextra/i3/1080040467/O1CN01cIa8L41FJvdfbH2VI_!!1080040467.png", width: 200, height: 80 },
active: { src: "https://img.alicdn.com/imgextra/i3/1080040467/O1CN01nEV2PZ1FJvddAuThZ_!!1080040467.png", width: 200, height: 80 },
}
},
player: {
src: "https://img.alicdn.com/imgextra/i3/1080040467/O1CN01HikdDK1FJvdXa8fK1_!!1080040467.png",
moveY: false,
width: 87,
height: 396,
autoOps: {
// 自动移动设置参数
speed: 5
},
},
penwu: {
width: 179,
height: 421,
boomSpeed: 0.2,
anchor: { x: 0.5, y: 1 },
bound: {
left: 48,
top: 88,
right: 48,
bottom: 0
},
srcArr: [
{ src: "https://img.alicdn.com/imgextra/i4/1080040467/O1CN01krwP7Q1FJvdhAzWR6_!!1080040467.png", width: 179, height: 421 },
{ src: "https://img.alicdn.com/imgextra/i3/1080040467/O1CN01HHHSFu1FJvdZ2Bttj_!!1080040467.png", width: 179, height: 421 },
{ src: "https://img.alicdn.com/imgextra/i3/1080040467/O1CN01L7FWJv1FJvdZbep2l_!!1080040467.png", width: 179, height: 421 },
{ src: "https://img.alicdn.com/imgextra/i4/1080040467/O1CN01FP0JiE1FJvdcnJHWU_!!1080040467.png", width: 179, height: 421 },
]
},
triggerType: "drag",//click:点击瓶子触发喷雾 drag:拖动瓶子放开时触发喷雾 不传递则不触发,需手动调用send触发
}),
},
onLoad(query) {
},
playFun() {
this.gameComponent.onEvent("start");
},
resetFun() {
this.gameComponent.onEvent("reset");
},
sendFun() {
// 手动触发游戏
this.gameComponent.onEvent("send");
},
onRef(game) {
this.gameComponent = game;
console.log("进入游戏")
},
onInitDone() {
// my.alert({
// content: "游戏初始化完成"
// })
// this.playFun();
},
onUpdate(ops) {
// { totalScore: 0, imgObj: { } }
console.log(ops)
},
onGameOver({ totalScore }) {
console.log(totalScore)
}
})
- xaml
<game gameSource="{{gameSource}}"
onRef="onRef"
onInitDone="onInitDone"
onUpdate="onUpdate"
onGameOver="onGameOver"
/>