0.0.3 • Published 7 years ago

phaser-dragonbones v0.0.3

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

Phaser + DragonBones

Capture.png

Phaser

DragonBones Animator

original repo

Installing

Make clone

Clone without submodules

> git clone https://github.com/raksa/phaser-dragonbones.git

Clone with submodules (will make big size of transfer git repo)

> git clone --recurse-submodules https://github.com/raksa/phaser-dragonbones.git

Make compiling

> cd phaser-dragonbones

> npm install

> npm run compile

Make running

> npm run start

test example in  "example" folder

Usage

Current test version:

  • Phaser: 2.6.2

  • DragonBones API: 4.5

  • DragonBones Data Format: 4.5

include:

Via bower

> bower install phaser-dragonbones
<script src="example/lib/dragonBones.js"></script>
<script src="built/dragonBonesPhaser.min.js"></script>
{

    init: function() {

        this.dragonBonesPlugin = this.game.plugins.add(Rift.DragonBonesPlugin);

    },

    preload: function () {

        this.dragonBonesPlugin.addResourceByNames("key",
            "path/to/skeleton.json", "path/to/texture.json", "path/to/texture.png");

        this.dragonBonesPlugin.loadResources();
    },

    create: function () {

        var x = this.world.width / 2;

        var y = 3 * this.world.height / 4;

        var sprite = this.dragonBonesPlugin.getArmature("key");

        sprite.position.setTo(x, y);

        sprite.scale.setTo(0.6);

        this.world.add(sprite);

        var names = sprite.animation._animationNames;

        sprite.animation.play(names[0]);
    }

}