The Pha[ser] [Rising Pi]x[el] Elf [Games Works] library.
Go phax your elf.
Online documentation at http://risingpixel.github.io/phaxelf-lib
A random set of utility classes to build better Phaser games.
To install this library in your project:
npm install --save phaxelf-libOr with yarn:
yarn add phaxelf-libAfter installing the library, you can just require what you need from the package:
import { Drag } from 'phaxelf-lib';
mySprite = game.add.sprite(0, 0, 'somesprite.png');
Drag.enable(mySprite);Phaxelf provides a set of extensions for the default phaser methods, to handle scaling, coordinates and tweening easier.
To use them, you have to initialize it manually in your game startup.
import { Extensions } from 'phaxelf-lib';
// ... your main file
Extensions.init(LU);
/// ... other stuffThen, you can just find them ready as methods.
mySpriteInAScaledGroup = game.add.sprite(0, 0, 'sprite1.png');
mySpriteInAnotherMessyScaledGroup = game.add.sprite(0, 0, 'sprite1.png');
mySpriteInAScaledGroup.$$moveTo(mySpriteInAnotherMessyScaledGroup);sprite.$$contains(new Phaser.Point(100, 100)); // => true/falselet tween = sprite.$$tween({ x: 100, y: 100}, 1000, { repeat: 10, yoyo: true, autostart: true });let tween = sprite.$$tintTween(0xff0000, 1000);let tween = sprite.$$scaleTween({ x: '+0.5', y: '+0.5' }, 1000, { yoyo: true });Complete reference here.
To test this library locally, first of all install the npm dependencies. Remember to run it every time you update them:
npm installBuild the library by using gulp:
npm run startIt will automatically rebuild the sources when you change the files.
Then, to add it in your project, specifying the current folder where you've downloaded the library sources.
npm install --save path/to/phaxelf-lib # Replace this with your library pathYou may need to re-run this two last commands during the development cycle to update the sources in your project.
You can concatenate this commands to make the development cycle easier, like:
npm install --save path/to/phaxelf-lib && npm run start:devOn windows:
npm install --save path\to\phaxelf-lib; npm run start:devDocs are auto-generated by the gulp task.
To update the online documentation, just run:
npm run docs:publish- Make sure you're logged in in npm, using
npm whoami. If not, just register usingnpm adduser. - Update the version number in the
package.jsonfile, using semantic versioning. To achieve this, usenpm version patch, replacingpatchwith one ofpatch,minor,major. - Run
npm publishto publish the new release