0.1.5 • Published 3 years ago

gm-game-tappop v0.1.5

Weekly downloads
220
License
ISC
Repository
-
Last release
3 years ago

gm-game-tappop

点击元素

安装
npm install gm-game-tappop
使用
必须开启 "enableSkia": "true"
  • json
{
    "usingComponents": {
        "game-tappop": "gm-game-tappop/tappop"
    }
}
  • js
Page({
  data: {
    renderGame: true,
    gameSource: {
      speed: 5,//初始速度
      maxSpeed: 10,//最大速度
      speedStep: 0,//递增速度
      speedStepHeight: 200,//递增高度(没隔递增高度增加对应的递增速度)
      firstShowHeight: 0,//初始元素显示坐标
      JGH: 150,//元素之间间隔的高度
      scorePos: {
        src: "https://img.alicdn.com/imgextra/i2/1080040467/O1CN01860rPU1FJvcXObrcF_!!1080040467.png",
        width: 91,
        height: 45,
        left: 614,
        top: 217,
        scoreTop: 280,//分数值顶部位置
        scoreLeft: 660,//分数值最左边位置
        scoreCenter: 660,
        // 分数值图片 0 - 9
        numArr: [
          { src: "https://img.alicdn.com/imgextra/i3/1080040467/O1CN01jzb0Ft1FJvcjRblMG_!!1080040467.png", width: 46, height: 58, val: 0 },
          { src: "https://img.alicdn.com/imgextra/i1/1080040467/O1CN01idMx3Z1FJvcmTpD5P_!!1080040467.png", width: 46, height: 58, val: 1 },
          { src: "https://img.alicdn.com/imgextra/i2/1080040467/O1CN01slKNYh1FJvcdN3x3C_!!1080040467.png", width: 46, height: 58, val: 2 },
          { src: "https://img.alicdn.com/imgextra/i1/1080040467/O1CN01mIH2VQ1FJvcdxe5ak_!!1080040467.png", width: 46, height: 58, val: 3 },
          { src: "https://img.alicdn.com/imgextra/i3/1080040467/O1CN010LzQcC1FJvchCDCxI_!!1080040467.png", width: 46, height: 58, val: 4 },
          { src: "https://img.alicdn.com/imgextra/i4/1080040467/O1CN01D8x76J1FJvckQRe39_!!1080040467.png", width: 46, height: 58, val: 5 },
          { src: "https://img.alicdn.com/imgextra/i4/1080040467/O1CN013b7pIh1FJvcdxgRA5_!!1080040467.png", width: 46, height: 58, val: 6 },
          { src: "https://img.alicdn.com/imgextra/i4/1080040467/O1CN01Izd4Aw1FJvcl4n90p_!!1080040467.png", width: 46, height: 58, val: 7 },
          { src: "https://img.alicdn.com/imgextra/i3/1080040467/O1CN01Gjo3mL1FJvcXMZS25_!!1080040467.png", width: 46, height: 58, val: 8 },
          { src: "https://img.alicdn.com/imgextra/i4/1080040467/O1CN01otlKor1FJvciJD56i_!!1080040467.png", width: 46, height: 58, val: 9 },
        ],
      },
      timePos: {
        src: "https://img.alicdn.com/imgextra/i4/1080040467/O1CN01mjTQ4i1FJvcj49h8B_!!1080040467.png",
        width: 88,
        height: 44,
        left: 60,
        top: 217,
        time: 30,//倒计时时间
        timeTop: 280,//倒计时数字顶部位置
        // timeleft: -999,//倒计时第一位数字左侧位置,第二位数紧跟其后
        // timeRight: 130,//倒计时最后一位数字右侧位置,第三位数字在其前面
        center: 100,//倒计时时间中间位置,如果有该字段,timeLeft和timeRight无效
        endImg: { src: "https://img.alicdn.com/imgextra/i1/1080040467/O1CN01pXmzCz1FJvcj2Lqgs_!!1080040467.png", width: 42, height: 58 },//跟在倒计时后面
        // 时间数字图片 0 - 9
        numArr: [
          { src: "https://img.alicdn.com/imgextra/i3/1080040467/O1CN01jzb0Ft1FJvcjRblMG_!!1080040467.png", width: 46, height: 58, val: 0 },
          { src: "https://img.alicdn.com/imgextra/i1/1080040467/O1CN01idMx3Z1FJvcmTpD5P_!!1080040467.png", width: 46, height: 58, val: 1 },
          { src: "https://img.alicdn.com/imgextra/i2/1080040467/O1CN01slKNYh1FJvcdN3x3C_!!1080040467.png", width: 46, height: 58, val: 2 },
          { src: "https://img.alicdn.com/imgextra/i1/1080040467/O1CN01mIH2VQ1FJvcdxe5ak_!!1080040467.png", width: 46, height: 58, val: 3 },
          { src: "https://img.alicdn.com/imgextra/i3/1080040467/O1CN010LzQcC1FJvchCDCxI_!!1080040467.png", width: 46, height: 58, val: 4 },
          { src: "https://img.alicdn.com/imgextra/i4/1080040467/O1CN01D8x76J1FJvckQRe39_!!1080040467.png", width: 46, height: 58, val: 5 },
          { src: "https://img.alicdn.com/imgextra/i4/1080040467/O1CN013b7pIh1FJvcdxgRA5_!!1080040467.png", width: 46, height: 58, val: 6 },
          { src: "https://img.alicdn.com/imgextra/i4/1080040467/O1CN01Izd4Aw1FJvcl4n90p_!!1080040467.png", width: 46, height: 58, val: 7 },
          { src: "https://img.alicdn.com/imgextra/i3/1080040467/O1CN01Gjo3mL1FJvcXMZS25_!!1080040467.png", width: 46, height: 58, val: 8 },
          { src: "https://img.alicdn.com/imgextra/i4/1080040467/O1CN01otlKor1FJvciJD56i_!!1080040467.png", width: 46, height: 58, val: 9 },
        ],
      },
      energyArr: [
        {
          src: "https://img.alicdn.com/imgextra/i4/1080040467/O1CN01LKnYDD1FJvchkRBw0_!!1080040467.png", width: 238, height: 251, val: 1, showHeight: 0, probability: 1, bound: { left: 56, right: 56, top: 70, bottom: 56 },
          activeSpeed: 0.1,
          activeImg: [
            { src: "https://img.alicdn.com/imgextra/i4/1080040467/O1CN01W3N5hx1FJvckz8xxC_!!1080040467.png", width: 110, height: 109 },
          ]
        },//bound:障碍物触碰的边界 相对障碍物图片边界向指定方向缩进
        {
          src: "https://img.alicdn.com/imgextra/i2/1080040467/O1CN01hNvw5E1FJvcglXkWB_!!1080040467.png", width: 289, height: 305, val: 1, showHeight: 0, probability: 1, bound: { left: 68, right: 68, top: 88, bottom: 68 },
          activeSpeed: 0.1,
          activeImg: [
            { src: "https://img.alicdn.com/imgextra/i1/1080040467/O1CN01Bkl4rR1FJvcmWdl2N_!!1080040467.png", width: 191, height: 188 },
          ]
        },//bound:障碍物触碰的边界 相对障碍物图片边界向指定方向缩进
        {
          src: "https://img.alicdn.com/imgextra/i1/1080040467/O1CN01kKfIo91FJvcgle3jJ_!!1080040467.png", width: 231, height: 244, val: 1, showHeight: 0, probability: 1, bound: { left: 54, right: 54, top: 70, bottom: 54 },
          activeSpeed: 0.1,
          activeImg: [
            { src: "https://img.alicdn.com/imgextra/i4/1080040467/O1CN01HbnZtb1FJvcmWgEsc_!!1080040467.png", width: 172, height: 169 },
          ]
        },//bound:障碍物触碰的边界 相对障碍物图片边界向指定方向缩进
      ],
      padding: {
        top: 0
      }
    },
  },
  onLoad() {
  },
  onRef(game) {
    this.gameComponent = game;
  },
  beginFun() {
    this.gameComponent.start();
  },

  onFinish(obj) {
    // obj {score:总分数,type:"timeout"}
    my.alert({
      content: "游戏结束" + obj.score
    })
  },
  onInitDone() {
    // my.alert({
    //   content: "游戏初始化完成"
    // })
    this.beginFun();
  },
  onUpdate(item) {
    // console.log("------", item.imgObj)
    // item.imgObj 返回图片对象
    /* my.alert({
      content: "游戏消除了"
    }) */
  },
});
  • xaml
  <game-tappop
    gameSource="{{gameSource}}"
    onRef="onRef"
    onFinish="onFinish" 
    onInitDone="onInitDone" 
    onUpdate="onUpdate" 
  />
0.1.4

3 years ago

0.1.3

3 years ago

0.1.5

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago