phaxelf-lib v0.5.0
phaxelf-lib
The Phaserxel Elf Games Works library.
Go phax your elf.
Online documentation at http://risingpixel.github.io/phaxelf-lib
What is this?
A random set of utility classes to build better Phaser games.
Installation
To install this library in your project:
npm install --save phaxelf-libOr with yarn:
yarn add phaxelf-libExample Usage
Quickstart
After 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);Extensions
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.
Moving a sprite in the hierarchy in the same screen position of another one
mySpriteInAScaledGroup = game.add.sprite(0, 0, 'sprite1.png');
mySpriteInAnotherMessyScaledGroup = game.add.sprite(0, 0, 'sprite1.png');
mySpriteInAScaledGroup.$$moveTo(mySpriteInAnotherMessyScaledGroup);Check if a point is contained in a sprite, no physics
sprite.$$contains(new Phaser.Point(100, 100)); // => true/falseShortcut for tweens
let tween = sprite.$$tween({ x: 100, y: 100}, 1000, { repeat: 10, yoyo: true, autostart: true });Tint tweening
let tween = sprite.$$tintTween(0xff0000, 1000);Scale tweening
let tween = sprite.$$scaleTween({ x: '+0.5', y: '+0.5' }, 1000, { yoyo: true });Complete reference here.
Library Local Development
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.
Pro tip
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 generation and publishing
Docs are auto-generated by the gulp task.
To update the online documentation, just run:
npm run docs:publishLibrary publishing
- 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