MCPcopy Index your code
hub / github.com/cristianbote/phaser-state-transition

github.com/cristianbote/phaser-state-transition @2.5.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release 2.5.1 ↗ · + Follow
22 symbols 29 edges 7 files 2 documented · 9% updated 6y ago2.5.1 · 2018-03-08★ 1773 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

State Transition Plugin for Phaser

npm version

About

Currently the switch between states is really static and a game should be able to transition between states. Therefore, this plugin does exactly that: draws the game.world into a renderTexture which is rendered on a sprite, and finally it's tweening that sprite.

Transition Examples

https://codepen.io/cristianbote/full/GjgVxg

How to use it

You have several options here including es6 imports.

Npm

npm install phaser-state-transition --save

And then import it in your project

import "phaser-state-transition";

The plugin needs the Phaser framework to work, therefore you should make sure that this is included before the plugin's import.

Straight but nor recommended

Just download the dist/phaser-state-transition.umd.js file and you're done, but this is not the recommended way. You should use it via npm. You have better control on what version you're keeping locally.

Usage

The easiest way to use it, is by just passing a transition for entering.

import { createTransition } from "phaser-state-transition";

const EnteringTransition = createTransition({
    props: {
        x: game => game.width
    }
});

game.state.start("stateName", EnteringTransition);

The transition options to pass in are basically just some instructions for the plugin, to handle the how of the transition. You'll find there are other properties inside, like ease, duration and other properties that are not that important to have nice transitions.

API

StateTransitionPlugin

The plugin class. Normally you should not work on this class, but you could extend it if needed. The plugin does not need a class to be working.

createTransition(options)

This helper function, generates a transition object to be passed along the game.state.start method.

The default duration would be 500ms and the ease function Phaser.Easing.Exponential.InOut

  • @param {object} options The options to create a transition object
  • @returns {object} The transition object to be passed along the game.start.state

Feedback

If there's something you think it could be improved let me know, or create a pr.

Core symbols most depended-on inside this repo

cleanup
called by 2
src/core/state-manager-start.js
go
called by 2
src/core/slide.js
destroy
called by 2
src/transition/transition.js
shouldRenderBasedOnCameraPosition
called by 1
src/core/content-snapshot.js
start
called by 1
src/transition/transition.js
_prepareTargetForTweening
called by 1
src/transition/transition.js
createTransition
called by 0
src/index.js
constructor
called by 0
src/core/content-snapshot.js

Shape

Method 9
Class 8
Function 5

Languages

TypeScript100%

Modules by API surface

src/transition/transition.js8 symbols
src/core/slide.js4 symbols
src/core/content-snapshot.js4 symbols
src/index.js3 symbols
src/core/state-manager-start.js2 symbols
src/core/StateTransition.js1 symbols

For agents

$ claude mcp add phaser-state-transition \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page