40phaser 中文文档教程

发布于 3年前 浏览 160 项目主页 更新于 3年前

40Phaser

代码风格:更漂亮 圈CINPM 版本 Powered by Phaser< /a>

Codecademy 花哨的 schmancy 404 页面。

Usage

在 npm 上安装 40phaser 包:

npm i 40phaser

因为这个包需要图像资源,所以你需要使用像 webpackrollup 来编译您在网站上使用的脚本。 此 repo 中包含使用汇总的此设置示例,并用于本地开发。

window.Phaser 下已经有 Phaser 的网页中,导入并调用 launch40Phaser启动游戏的函数:

import { launch40Phaser } from "40phaser";

window.onload = () => {
    launch40Phaser();
};

或者,如果 Phaser 在全局不可用,您可以将其作为 phaser 传递给游戏:可以向

import { launch40Phaser } from "40phaser";
import phaser from "phaser";

window.onload = () => {
    launch40Phaser({ phaser });
};

Events

提供一个 on 对象>launch40Phaser 对象,其函数在 endgamestart 下——对应于游戏中的这三个 Phaser 场景。

launch40Phaser({
    on: {
        game: action => console.log('[game]', action),   
    },
});

on.end

  • on.end("build-your-own"): User navigates to the the Learn Phaser course
  • on.end("game"): User restarts the game

on.game

  • on.game("death"): User dies by falling through the floor
  • on.game("jump"): User requests to jump
  • on.game("pause"): User unpauses
  • on.game("unpause"): User pauses

on.start

  • on.start("build-your-own"): User navigates to the Learn Phaser course
  • on.start("contribute"): User navigates to the GitHub repository
  • on.start("game"): User starts the game

Development

请参阅 Development.md! ✨

Contribution Guidelines

我们很乐意让您做出贡献! 检查问题跟踪器是否有标记为接受 PR 以查找错误修复和社区可以处理的功能请求。 如果这是您第一次使用此代码,Good First issue 标签表示良好的介绍性问题。

请注意,此项目随 贡献者契约 一起发布。 参与此项目即表示您同意遵守其条款。 请参阅 CODEOFCONDUCT.md

40Phaser

Code Style: Prettier Circle CINPM versionPowered by Phaser

Codecademy's fancy schmancy 404 page.

Usage

Install the 40phaser package on npm:

npm i 40phaser

Because this package requires image assets, you'll need to use a bundler like webpack or rollup to compile the script you use on your site. An example of this setup using rollup is included in this repo and used for local development.

In a webpage that already has Phaser available under window.Phaser, import and call the launch40Phaser function to start the game:

import { launch40Phaser } from "40phaser";

window.onload = () => {
    launch40Phaser();
};

Alternately, if Phaser isn't available globally, you may pass it to the game as phaser:

import { launch40Phaser } from "40phaser";
import phaser from "phaser";

window.onload = () => {
    launch40Phaser({ phaser });
};

Events

An on object may be provided to the launch40Phaser object with functions under end, game, and start -- corresponding to those three Phaser scenes in the game.

launch40Phaser({
    on: {
        game: action => console.log('[game]', action),   
    },
});

on.end

  • on.end("build-your-own"): User navigates to the the Learn Phaser course
  • on.end("game"): User restarts the game

on.game

  • on.game("death"): User dies by falling through the floor
  • on.game("jump"): User requests to jump
  • on.game("pause"): User unpauses
  • on.game("unpause"): User pauses

on.start

  • on.start("build-your-own"): User navigates to the Learn Phaser course
  • on.start("contribute"): User navigates to the GitHub repository
  • on.start("game"): User starts the game

Development

See Development.md! ✨

Contribution Guidelines

We'd love to have you contribute! Check the issue tracker for issues labeled Accepting PRs to find bug fixes and feature requests the community can work on. If this is your first time working with this code, the Good First issue label indicates good introductory issues.

Please note that this project is released with a Contributor Covenant. By participating in this project you agree to abide by its terms. See CODEOFCONDUCT.md.

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文