npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gm-game-ball

v1.0.0

Published

# 躲避障碍物小游戏

Downloads

1

Readme

Gm-game-ball

躲避障碍物小游戏

安装
npm install gm-game-ball
使用
  • json
{
    "usingComponents": {
        "gm-game-ball": "/pages/components/ballGame/ballGame"
    }
}
  • js
Page({
  data: {
  	//分数背景图片位置参数
    scorePos: {
      src: "https://img.alicdn.com/imgextra/i1/1080040467/O1CN01TlwpbW1FJvZ2Q5aGq_!!1080040467.png",
      width: 136,
      height: 43,
      left: 500,
      top: 100,
      txt: {
      	//分数文字参数
        color: "#fff",
        fontSize: 14,//换成px值传递
        textHeight: 10,//文字左下角Y坐标(高度)
        left: 510,
        top: 110
      }
    },
    //游戏图片数据
    gameSource: {
    	//玩家
      playerInfo: { src: "https://img.alicdn.com/imgextra/i4/1080040467/O1CN01htfguA1FJvZIgAvxd_!!1080040467.png", width: 186, height: 338 },
      //障碍物
      barrierArr: [
        { src: "https://img.alicdn.com/imgextra/i2/1080040467/O1CN01A5w8hq1FJvZcCaIff_!!1080040467.png", width: 243, height: 100, bound: { left: 0, right: 0, top: 0, bottom: 0 } },//bound:障碍物触碰的边界 相对障碍物图片边界向指定方向缩进
        { src: "https://img.alicdn.com/imgextra/i2/1080040467/O1CN01A5w8hq1FJvZcCaIff_!!1080040467.png", width: 243, height: 100, bound: { left: 0, right: 0, top: 0, bottom: 0 } },
        { src: "https://img.alicdn.com/imgextra/i2/1080040467/O1CN01A5w8hq1FJvZcCaIff_!!1080040467.png", width: 243, height: 100, bound: { left: 0, right: 0, top: 0, bottom: 0 } },
        { src: "https://img.alicdn.com/imgextra/i2/1080040467/O1CN01A5w8hq1FJvZcCaIff_!!1080040467.png", width: 243, height: 100, bound: { left: 0, right: 0, top: 0, bottom: 0 } },
      ],
      //能量
      energyArr: [
        { src: "https://img.alicdn.com/imgextra/i4/1080040467/O1CN014XhPxP1FJvZKH2Atm_!!1080040467.png", width: 94, height: 94, val: 6, showHeight: 0 },//showHeight:出现的高度
        { src: "https://img.alicdn.com/imgextra/i3/1080040467/O1CN01LY1v8r1FJvZMipHyn_!!1080040467.png", width: 94, height: 94, val: 2, showHeight: 0 },
        { src: "https://img.alicdn.com/imgextra/i1/1080040467/O1CN01UKH6jB1FJvZN3Fe7y_!!1080040467.png", width: 94, height: 94, val: 5, showHeight: 0 },
        { src: "https://img.alicdn.com/imgextra/i1/1080040467/O1CN016ALiAh1FJvZHfakok_!!1080040467.png", width: 94, height: 94, val: 3, showHeight: 0 },
      ]
    }
  },
  onLoad() { },
  overFun() {
  	//游戏结束
    this.ballGameComponent.stop();
  },
  beginFun() {
  	//游戏开始
    this.ballGameComponent.start();
  },
  goonFun(){
  	//游戏继续
    this.ballGameComponent.goOn();
  },
	//回调方法
  onFinish() { },
  onStart() { },
  onUpdate() { },
});
  • xaml
  <gm-game-ball 
                speed="{{2}}" //游戏速度
                audio="{{''}}" //音乐
                speed-step="{{0.1}}"//速度递增值 
                speed-step-height="{{200}}"//指定高度递增一次速度
                barrier-height-step="{{0}}"//障碍物间隔距离递减速度 为0时,两个障碍物之间固定高度
                barrier-max-height="{{2.5}}"//障碍物之间的最大高度,此处值为玩家高度的倍数
                no-over="{{!true}}"//true游戏触发到障碍物不结束,会回调onUpdate传入障碍物
                player-bottom="{{10}}"//玩家离底部距离
                nosingleenergy="{{false}}"//不需要单独一行能量值 false:(障碍物+能量)-》(能量) true:(障碍物+能量)-》(障碍物+能量)
                gameSource="{{gameSource}}"//游戏图片数据
                score-pos="{{scorePos}}"//分数位置属性
                onFinish="onFinish" 
                onStart="onStart" 
                onUpdate="onUpdate" 
  ></gm-game-ball>