0.5.0 • Published 5 years ago

phaxelf-lib v0.5.0

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

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-lib

Or with yarn:

yarn add phaxelf-lib

Example 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 stuff

Then, 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/false

Shortcut 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 install

Build the library by using gulp:

npm run start

It 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 path

You 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:dev

On windows:

npm install --save path\to\phaxelf-lib; npm run start:dev

Docs generation and publishing

Docs are auto-generated by the gulp task.

To update the online documentation, just run:

npm run docs:publish

Library publishing

  • Make sure you're logged in in npm, using npm whoami. If not, just register using npm adduser.
  • Update the version number in the package.json file, using semantic versioning. To achieve this, use npm version patch, replacing patch with one of patch, minor, major.
  • Run npm publish to publish the new release
0.5.0

5 years ago

0.4.1

6 years ago

0.4.0

6 years ago

0.3.2

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago