Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

State transition plugin for Phaser.js

License

NotificationsYou must be signed in to change notification settings

cristianbote/phaser-state-transition

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 thegame.world into arenderTexture which is rendered on asprite, 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 thePhaser framework to work, therefore you should make sure that this is included before the plugin's import.

Straight but nor recommended

Just download thedist/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";constEnteringTransition=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 thehow 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 thegame.state.start method.

The default duration would be500ms and the ease functionPhaser.Easing.Exponential.InOut

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

Feedback

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

About

State transition plugin for Phaser.js

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp