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 🙏

© 2025 – Pkg Stats / Ryan Hefner

cocos-game-scaffold

v1.0.0

Published

Cocos Creator 游戏项目脚手架,快速创建游戏项目

Readme

Cocos Creator 游戏项目脚手架

基于 Cocos Creator 3.8.6 的游戏项目脚手架,一键创建包含完整基础架构的游戏项目

✨ 特性

  • 🎮 基于 Cocos Creator 3.8.6
  • 📦 Mobx 状态管理
  • 🌐 WebSocket 网络通信封装
  • 🎵 音频管理系统
  • 📝 阿里云 SLS 日志系统
  • 📡 事件系统
  • 📊 ThinkingData 数据分析
  • 🌍 国际化支持
  • 💪 完整的 TypeScript 支持

📦 安装

全局安装

npm install -g cocos-game-scaffold

本地安装

npm install cocos-game-scaffold

🚀 使用

创建新项目

# 使用完整命令
cocos-scaffold create my-game

# 或使用简写
ccs create my-game

确认后,脚手架会自动:

  • 复制项目模板
  • 生成唯一的项目 UUID
  • 配置项目文件

在当前目录初始化

cd my-game
ccs init

安装依赖并打开

cd my-game
npm install
# 使用 Cocos Creator 3.8.6 打开项目

📁 项目结构

生成的项目包含以下目录:

my-game/
├── assets/              # 游戏资源
│   ├── resources/      # 动态资源(音频、字体、国际化等)
│   ├── scene/         # 场景文件
│   └── script/        # TypeScript 脚本
│       ├── base/      # 基础框架(网络、音频、日志等)
│       ├── manager/   # 管理器
│       ├── service/   # 服务层
│       └── store/     # 状态管理
├── build-templates/    # 构建模板
├── settings/          # 项目配置
├── package.json
├── tsconfig.json
└── .gitignore

🛠️ 核心功能

状态管理(Mobx)

import { makeAutoObservable } from 'mobx';

export class GameStore {
  score: number = 0;
  
  constructor() {
    makeAutoObservable(this);
  }
  
  addScore(value: number) {
    this.score += value;
  }
}

网络通信

import Socket from './base/net/Socket';

const socket = new Socket('ws://your-server.com');
socket.send('message', { data: 'hello' });

事件系统

import emitter from './base/event/emitter';

// 监听事件
emitter.on('game-start', (data) => {
  console.log('游戏开始', data);
});

// 触发事件
emitter.emit('game-start', { level: 1 });

音频管理

import AudioMgr from './base/audio/AudioMgr';

// 播放背景音乐
AudioMgr.playMusic('bgm');

// 播放音效
AudioMgr.playSound('click');

📝 配置

修改设计分辨率

编辑 settings/v2/packages/project.json

{
  "general": {
    "designResolution": {
      "width": 750,
      "height": 1624
    }
  }
}

配置网络地址

编辑 assets/script/const/Net.ts

🔧 命令

  • ccs create <project-name> - 创建新项目
  • ccs init - 在当前目录初始化项目
  • ccs --version - 查看版本
  • ccs --help - 查看帮助

📚 依赖

项目依赖

  • mobx@^5.15.7 - 状态管理
  • @aliyun-sls/web-track-browser@^0.3.9 - 日志服务

❓ 常见问题

如何更新脚手架?

npm update -g cocos-game-scaffold

如何卸载?

npm uninstall -g cocos-game-scaffold

命令找不到?

检查 npm 全局目录是否在 PATH 中:

npm config get prefix

📄 许可证

MIT License

🤝 贡献

欢迎提交 Issue 和 Pull Request!


Happy Coding! 🎮